VB.NET Owned Forms in Visual Basic .NET

In this article, I will explain you about Owned Forms in Visual Basic .NET.
  • 4220

Owned Forms

In Visual Basic .NET we can also create owned forms. An owned form is tied to its Owner form. When a form is owned by another form, it is closed or hidden with the owner form. The owned form will be always displayed in front of its owner form, no matter which is the active form. When you minimize the owner forms and all its owned forms, they count as one icon in the windows taskbar. To make a form owned by another form, call the AddOwnedForm method and it 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. The following code will show you how to create the owned forms. Drag a Button1 from the toolbox onto the Form1 and place the following code in the click event of Button1.


Public Class Form1
    Dim Owned1 As New Form()
    Private Sub Button1_Click(ByVal sender As System.ObjectByVal e As System.EventArgs)Handles Button1.Click
        'Adding an Owned Form to the current form
        'Displaying the Owned Form
End Class

The image shows you the output of above code:



I hope this article will help you to understand about Owned Forms in Visual Basic .NET.


More Articles

© 2020 DotNetHeaven. All rights reserved.