Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: VB.NET
Expertise: Intermediate
Dec 1, 2001



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Working with owned forms

If a form owns another form, the owned form will be always displayed in front of its owner form, no matter which is the active form. This makes owned forms ideal for implementing tool and palette windows. Another feature of owned forms: when the user closes or minimizes the owner form, all the owned forms are also closed or minimized. When minimized, the owner forms and all its owned forms count as one icon in the Windows taskbar.

In Visual Basic 6, you can display a form as an owned form by passing Me as the second argument of the Show method, as in:

' The Visual Basic 6 way for creating an owned form
Dim frm As New CalleeForm
frm.Show , Me
You can't pass any argument to the Show method under Visual Basic .NET, but you declare that the callee form is owned by the caller form by invoking the AddOwnedForm method:

' The Visual Basic .NET way for creating an owned form
Dim frm As New CalleeForm()
' Add this form to the list of owned form.
A form can detect whether it is being owned by another form using the Owner property; a form can enumerate its owned forms by iterating over the collection returned by the OwnedForms property.
Francesco Balena
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date