MainMenu.GetForm Metódus
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Lekéri a Form vezérlőt tartalmazó vezérlőt.
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
Válaszok
Ez Form a vezérlő tárolója. Akkor adja null vissza, ha a MainMenu jelenleg nem egy űrlapon található.
Példák
Az alábbi példakód a GetForm metódus használatával állapítja meg, hogy egy jelenleg az űrlaphoz szülőként van-e MainMenu beszkenve. Ha a példakódban GetForm szereplő hívás nem ad vissza null, a kód klónozza a metódus menüstruktúráját MainMenuCloneMenu . A kód ezután igaz értékre állítja RightToLeft a MainMenu tulajdonságot az új példányon, és létrehoz egy olyan tulajdonságotMainMenu, amely a jobbról balra szöveget támogató nyelvekhez használható. Ehhez a példához létre kell hoznia egy MainMenu , a névvel ellátott fájlt 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
Megjegyzések
Ez a tulajdonság lehetővé teszi annak megállapítását, hogy egy adott MainMenu egy adott űrlaphoz van-e fölérendelve. A tulajdonságot általában akkor használják, ha több MainMenu objektumot használnak egy űrlapon, és meg kell határoznia, hogy melyiket használja jelenleg egy űrlap.