Form.OwnedForms Form.OwnedForms Form.OwnedForms Form.OwnedForms Property

Definición

Obtiene una matriz de objetos Form que representa todos los formularios que posee dicho formulario.Gets an array of Form objects that represent all forms that are owned by this 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; }
member this.OwnedForms : System.Windows.Forms.Form[]
Public ReadOnly Property OwnedForms As Form()

Valor de propiedad

Form[]

Matriz de Form que representa los formularios que posee dicho formulario.A Form array that represents the owned forms for this form.

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar el OwnedForms propiedad para modificar todos los formularios que posee el formulario propietario.The following code example demonstrates how to use the OwnedForms property to modify all forms owned by the owner form. El primer método en el ejemplo agrega formularios a la matriz de formularios con propietario asociado con el formulario con propietario.The first method in the example adds forms to the array of owned forms associated with the owned form. El segundo método recorre en bucle todos los formularios que posee y cambia el título.The second method loops through all owned forms and changes the caption. Este ejemplo requiere que ambos métodos son invocados por un evento u otro método de un formulario.This example requires that both methods are called by an event or other method of a form.

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

Comentarios

Esta propiedad devuelve una matriz que contiene todos los formularios que posee dicho formulario.This property returns an array that contains all forms that are owned by this form. Para que un formulario pertenezca a otro, llame a la AddOwnedForm método.To make a form owned by another form, call the AddOwnedForm method. El formulario asignado al formulario propietario seguirá siendo propiedad hasta que el RemoveOwnedForm se llama al método.The form assigned to the owner form will remain owned until the RemoveOwnedForm method is called. También puede hacer que un formulario pertenezca a otro estableciendo el Owner propiedad con una referencia a su formulario propietario.You can also make a form owned by another by setting the Owner property with a reference to its owner form.

Cuando un formulario es propiedad de otra forma, se cierra o se oculta con el formulario propietario.When a form is owned by another form, it is closed or hidden with the owner form. Por ejemplo, considere la posibilidad de un formulario denominado Form2 que sea propiedad de un formulario denominado Form1.For example, consider a form named Form2 that is owned by a form named Form1. Si Form1 está cerrado o minimizada, Form2 también esté cerrado u oculto.If Form1 is closed or minimized, Form2 is also closed or hidden. Nunca se muestran formularios que posee detrás de su formulario propietario.Owned forms are also never displayed behind their owner form. Puede usar los formularios que posee para windows, como buscar y reemplazar windows, que no deben mostrarse detrás del formulario propietario cuando se selecciona el formato de propietario.You can use owned forms for windows such as find and replace windows, which should not be displayed behind the owner form when the owner form is selected.

Nota

Si el formulario es un formulario de elemento primario de la interfaz de múltiples documentos (MDI), esta propiedad devolverá todos los formularios que se muestran con la excepción de los formularios MDI secundarios que están abiertos.If the form is a multiple-document interface (MDI) parent form, this property will return all forms that are displayed with the exception of any MDI child forms that are currently open. Para obtener los formularios MDI secundarios abiertos en un formulario primario MDI, use el MdiChildren propiedad.To obtain the MDI child forms opened in an MDI parent form, use the MdiChildren property.

Se aplica a

Consulte también: