Form.OwnedForms Proprietà

Definizione

Ottiene una matrice di oggetti Form che rappresentano tutti i form appartenenti al form.

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à

Form[]

Matrice di Form che rappresenta i form appartenenti al form.

Attributi

Esempio

Nell'esempio seguente viene illustrato come usare 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 scorre 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 un modulo.

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 un modulo 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 un modulo di proprietà di un altro 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 al minimo, Form2 viene chiuso o nascosto. I moduli di proprietà non vengono mai visualizzati dietro il modulo proprietario. È possibile usare moduli di proprietà per finestre, ad esempio trovare e sostituire le finestre, che non devono essere visualizzate dietro il modulo proprietario quando viene selezionato il modulo proprietario.

Nota

Se il modulo è un modulo padre MDI (multiple-document interface), questa proprietà restituirà tutti i moduli visualizzati con l'eccezione di qualsiasi modulo figlio MDI attualmente aperto. Per ottenere i moduli figlio MDI aperti in un modulo padre MDI, usare la MdiChildren proprietà .

Si applica a

Vedi anche