Gets an array of Form objects that represent all forms that are owned by this form.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
This property returns an array that contains all forms that are owned by this form. To make a form owned by another form, call the AddOwnedForm method. The form assigned to the owner form will remain owned until the RemoveOwnedForm method is called. You can also make a form owned by another by setting the Owner property with a reference to its owner form.
When a form is owned by another form, it is closed or hidden with the owner form. For example, consider a form named Form2 that is owned by a form named Form1. If Form1 is closed or minimized, Form2 is also closed or hidden. Owned forms are also never displayed behind their owner form. 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.
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. To obtain the MDI child forms opened in an MDI parent form, use the MdiChildren property.
The following code example demonstrates how to use the property to modify all forms owned by the owner form. The first method in the example adds forms to the array of owned forms associated with the owned form. The second method loops through all owned forms and changes the caption. This example requires that both methods are called by an event or other method of a form.
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
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.