Form.AddOwnedForm(Form) Form.AddOwnedForm(Form) Form.AddOwnedForm(Form) Form.AddOwnedForm(Form) Method

Definición

Agrega un formulario con propietario al formulario.Adds an owned form to this form.

public:
 void AddOwnedForm(System::Windows::Forms::Form ^ ownedForm);
public void AddOwnedForm (System.Windows.Forms.Form ownedForm);
member this.AddOwnedForm : System.Windows.Forms.Form -> unit
Public Sub AddOwnedForm (ownedForm As Form)

Parámetros

ownedForm
Form Form Form Form

Form que será propiedad de este formulario.The Form that this form will own.

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar el AddOwnedForm método para mostrar un formulario como un formulario con propietario de otro formulario.The following code example demonstrates how to use the AddOwnedForm method to display a form as an owned form of another form. Una vez que se muestra el formulario con propietario, puede minimizar su formulario propietario y el formulario con propietario minimizará con él.Once the owned form is shown, you can minimize its owner form and the owned form will minimize with it. El ejemplo requiere que el código en el ejemplo se llama desde otro evento o método de un formulario.The example requires that the code in the example is called from another event or method of a form.

private:
   void ShowMyOwnedForm()
   {
      // Create an instance of the form to be owned.
      Form^ ownedForm = gcnew Form;

      // Set the text of the form to identify it is an owned form.
      ownedForm->Text = "Owned Form";

      // Add ownedForm to array of owned forms.
      this->AddOwnedForm( ownedForm );

      // Show the owned form.
      ownedForm->Show();
   }
private void ShowMyOwnedForm()
{
   // Create an instance of the form to be owned.
   Form ownedForm = new Form();
   // Set the text of the form to identify it is an owned form.
   ownedForm.Text = "Owned Form";
   // Add ownedForm to array of owned forms.
   this.AddOwnedForm(ownedForm);

   // Show the owned form.
   ownedForm.Show();
}
Private Sub ShowMyOwnedForm()
   ' Create an instance of the form to be owned.
   Dim ownedForm As New Form()
   ' Set the text of the form to identify it is an owned form.
   ownedForm.Text = "Owned Form"
   ' Add ownedForm to array of owned forms.
   Me.AddOwnedForm(ownedForm)

   ' Show the owned form.
   ownedForm.Show()
End Sub

Comentarios

El formulario asignado al formulario propietario seguirá propiedad hasta que el RemoveOwnedForm se llama al método.The form assigned to the owner form remains 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 devuelve 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 returns 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: