Far Away Developer

Sebastien Lachance

Archive for the 'Windows Forms' Category

Windows Forms

Windows Forms : Owner and Owned Forms

Posted by Sebastien Lachance on July 31, 2007

Since I’m pretty new to Windows Forms I learn a lot this days (I have done mainly ASP.NET development). I came across this feature and find it really interesting, Owner and Owned Forms. We can say that for the user it’s the same thing as the ShowDialog() method (grayed parent form, etc…). However, with ShowDialog there is no built-in way to make a link between the parent and the child form.

There is 2 way we can make this relation :

1. As a parameter in the Show() method

Form1 childForm = new Form1();
childForm.Show(this); //this is the parent form

2. Using the properties

Form1 childForm = new Form1();
childForm.Owner = this; //this is the parent form

And you can iterate through the child forms of the parent form with the OwnedForms property.

Posted in .NET, Windows Forms | 1 Comment »