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 siguiente se muestra cómo usar AddOwnedForm el método para mostrar un formulario como un formulario con propietario de otro formulario.The following 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 de propiedad, puede minimizar su formulario de propietario y el formulario de propiedad se 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 se llame al código del ejemplo 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 permanece en propiedad hasta que 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 sea propiedad de otro estableciendo la 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 otro formulario, está cerrado u oculto con el formulario propietario.When a form is owned by another form, it is closed or hidden with the owner form. Por ejemplo, considere un formulario denominado Form2 que es 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 minimizado, Form2 también está cerrado u oculto.If Form1 is closed or minimized, Form2 is also closed or hidden. Los formularios de propiedad nunca se muestran detrás de su formulario de propietario.Owned forms are also never displayed behind their owner form. Puede usar formularios de propiedad para ventanas como buscar y reemplazar ventanas, que no deben mostrarse detrás del formulario propietario cuando se selecciona el formulario 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 primario de 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 actualmente.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 MDI primario, utilice la MdiChildren propiedad.To obtain the MDI child forms opened in an MDI parent form, use the MdiChildren property.

Se aplica a

Consulte también: