Form.OwnedForms Proprietà
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene una matrice di Form oggetti che rappresentano tutti i moduli di proprietà di questo modulo.
public:
property cli::array <System::Windows::Forms::Form ^> ^ OwnedForms { cli::array <System::Windows::Forms::Form ^> ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.Form[] OwnedForms { get; }
[<System.ComponentModel.Browsable(false)>]
member this.OwnedForms : System.Windows.Forms.Form[]
Public ReadOnly Property OwnedForms As Form()
Valore della proprietà
Matrice Form che rappresenta i moduli di proprietà per questo modulo.
- Attributi
Esempio
Nell'esempio seguente viene illustrato come utilizzare la OwnedForms proprietà per modificare tutti i moduli di proprietà del modulo proprietario. Il primo metodo nell'esempio aggiunge moduli alla matrice di moduli di proprietà associati al modulo di proprietà. Il secondo metodo esegue un ciclo in tutti i moduli di proprietà e modifica la didascalia. Questo esempio richiede che entrambi i metodi vengano chiamati da un evento o da un altro metodo di una maschera.
private:
void AddMyOwnedForm()
{
// Create form to be owned.
Form^ ownedForm = gcnew Form;
// Set the text of the owned form.
ownedForm->Text = String::Format( "Owned Form {0}", this->OwnedForms->Length );
// Add the form to the array of owned forms.
this->AddOwnedForm( ownedForm );
// Show the owned form.
ownedForm->Show();
}
void ChangeOwnedFormText()
{
// Loop through all owned forms and change their text.
for ( int x = 0; x < this->OwnedForms->Length; x++ )
{
this->OwnedForms[ x ]->Text = String::Format( "My Owned Form {0}", x );
}
}
private void AddMyOwnedForm()
{
// Create form to be owned.
Form ownedForm = new Form();
// Set the text of the owned form.
ownedForm.Text = "Owned Form " + this.OwnedForms.Length;
// Add the form to the array of owned forms.
this.AddOwnedForm(ownedForm);
// Show the owned form.
ownedForm.Show();
}
private void ChangeOwnedFormText()
{
// Loop through all owned forms and change their text.
for (int x = 0; x < this.OwnedForms.Length; x++)
{
this.OwnedForms[x].Text = "My Owned Form " + x.ToString();
}
}
Private Sub AddMyOwnedForm()
' Create form to be owned.
Dim ownedForm As New Form()
' Set the text of the owned form.
ownedForm.Text = "Owned Form " + Me.OwnedForms.Length.ToString()
' Add the form to the array of owned forms.
Me.AddOwnedForm(ownedForm)
' Show the owned form.
ownedForm.Show()
End Sub
Private Sub ChangeOwnedFormText()
Dim x As Integer
' Loop through all owned forms and change their text.
For x = 0 To (Me.OwnedForms.Length) - 1
Me.OwnedForms(x).Text = "My Owned Form " + x.ToString()
Next x
End Sub
Commenti
Questa proprietà restituisce una matrice che contiene tutti i moduli di proprietà di questo modulo. Per creare una maschera di proprietà di un altro modulo, chiamare il AddOwnedForm metodo . Il modulo assegnato al modulo proprietario rimarrà di proprietà fino a quando non viene chiamato il RemoveOwnedForm metodo . È anche possibile creare una maschera di proprietà di un'altra impostando la Owner proprietà con un riferimento al relativo modulo proprietario.
Quando un modulo è di proprietà di un altro modulo, viene chiuso o nascosto con il modulo proprietario. Si consideri, ad esempio, un modulo denominato Form2 di proprietà di un modulo denominato Form1. Se Form1 è chiuso o ridotto a icona, Form2 viene anche chiuso o nascosto. I moduli di proprietà non vengono mai visualizzati dietro il modulo proprietario. È possibile utilizzare i moduli di proprietà per finestre come trova e sostituisci finestre, che non devono essere visualizzate dietro il modulo proprietario quando è selezionato il modulo proprietario.
Annotazioni
Se il modulo è un modulo padre MDI (Multiple-Document Interface), questa proprietà restituirà tutti i moduli visualizzati ad eccezione di tutti i moduli figlio MDI attualmente aperti. Per ottenere i moduli figlio MDI aperti in un modulo padre MDI, utilizzare la MdiChildren proprietà .