Click here to Skip to main content
15,896,726 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
i want to make a owner from in c#
how to do this..?
Posted
Comments
Sergey Alexandrovich Kryukov 20-Oct-12 0:35am    
What, broken MSDN? Or you need RTFM instructions? I have a link; all you need is to ask for it... :-)
--SA

1 solution

Here is how:

C#
myForm.Owner = someOtherForm;


You can also use System.Windows.Forms.Form.AddOwnedForm. Please see:
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.owner.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.addownedform.aspx[^].

For application consistency, it's very important to make all forms owned by other forms, except them main form; it's usually the best to have all forms owned by the main one. It's is only important that all ownership leads to the main form. If you don't do it, all forms would behave like that of independent application: a window of any different application may appear between the forms of your application in Z-order, which is not nice.

For the similar reason, it's good to assign the property ShowInTaskbar to false for all forms except the main one:
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.showintaskbar.aspx[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900