Condividi tramite


MainMenu.GetForm Metodo

Definizione

Ottiene l'oggetto Form che contiene questo controllo.

public:
 System::Windows::Forms::Form ^ GetForm();
public System.Windows.Forms.Form GetForm();
member this.GetForm : unit -> System.Windows.Forms.Form
Public Function GetForm () As Form

Restituisce

Oggetto Form che rappresenta il contenitore per questo controllo. Restituisce null se l'oggetto MainMenu non è attualmente ospitato in un modulo.

Esempio

Nell'esempio di codice seguente viene utilizzato il GetForm metodo per determinare se un oggetto MainMenu è attualmente padre del form. Se la chiamata nel codice di esempio a non restituisce nullGetForm , il codice clona la struttura di menu dell'oggetto MainMenu utilizzando il CloneMenu metodo . Il codice imposta quindi la RightToLeft proprietà su true nella nuova copia di MainMenu per creare un MainMenu oggetto che può essere usato per le lingue che supportano il testo da destra a sinistra. Questo esempio richiede che sia stato creato un MainMenu oggetto denominato mainMenu1.

void CloneMyMenu()
{
   // Determine if mainMenu1 is currently hosted on the form.
   if ( mainMenu1->GetForm() != nullptr )
   {
      // Create a copy of the MainMenu that is hosted on the form.
      MainMenu^ mainMenu2 = mainMenu1->CloneMenu();

      // Set the RightToLeft property for mainMenu2.
      mainMenu2->RightToLeft = ::RightToLeft::Yes;
   }
}
public void CloneMyMenu()
{
   // Determine if mainMenu1 is currently hosted on the form.
   if(mainMenu1.GetForm() != null)
   {
      // Create a copy of the MainMenu that is hosted on the form.
      MainMenu mainMenu2 = mainMenu1.CloneMenu();
      // Set the RightToLeft property for mainMenu2.
      mainMenu2.RightToLeft = RightToLeft.Yes;
   }
}
Public Sub CloneMyMenu()
    ' Determine if mainMenu1 is currently hosted on the form.
    If (mainMenu1.GetForm() IsNot Nothing) Then
        ' Create a copy of the MainMenu that is hosted on the form.
        Dim mainMenu2 As MainMenu = mainMenu1.CloneMenu()
        ' Set the RightToLeft property for mainMenu2.
        mainMenu2.RightToLeft = RightToLeft.Yes
    End If
End Sub

Commenti

Questa proprietà consente di determinare se un elemento specifico MainMenu è padre di una maschera. La proprietà viene in genere utilizzata quando vengono utilizzati più MainMenu oggetti in una maschera ed è necessario determinare quale oggetto è attualmente utilizzato da un modulo.

Si applica a

Vedi anche