Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
How to connect two forms? Suppose I have two forms - if I write form2.show then it display only form2.
But I want Form1 also attached with form2. I use form2.showdialogue but it is not working.
Posted 4-May-11 20:31pm
Edited 4-May-11 20:43pm
v2
Comments
OriginalGriff at 5-May-11 3:04am
   
Sorry, but that doesn't make much sense.
Please use the "Improve question" widget and try to explain your problem in better detail.
What does "connect two forms" mean? What does "Form1 also attached with form2" mean?
SAKryukov at 5-May-11 14:26pm
   
Very unclear indeed, but I got some idea, please see how I answered.
--SA
Legor at 5-May-11 3:25am
   
Unclear, be more precise.
Keith Barrow at 5-May-11 6:48am
   
No at all clear. What do you mean by "Form1 also attached with form2". What error are you getting? Can you post the code shown the form?
SAKryukov at 5-May-11 13:14pm
   
I have some idea what is should be, at least part of it -- please see my answer.
--SA

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You're very confused, so the question even does not make sense.
 
However, if you have more than one form in the same application, you need to link them with form ownership relationship. This helps to conveniently support some UI integrity in terms of form activation. You need to look at the property System.Windows.Forms.Form.Owner you need to set. Normally, your main form should own other forms (which is not so by default). A form should be added using System.Windows.Forms.Form.AddOwnedForm and removed using System.Windows.Forms.Form.RemoveOwnedForm; you can also use the property System.Windows.Forms.Form.OwnedForms.
 
Please see http://msdn.microsoft.com/en-us/library/system.windows.forms.form.aspx[^].
 
Also, consider setting the property System.Windows.Forms.Form.ShowInTaskbar to false for all owned forms. They will be shown on top of Z-order when a Owner form is shown, not independently. At the same time, the owned form can be sent on top and activated. The ownership only guarantees that no windows of other application will be placed between any forms of yours, which probably is what you require. If one form is send to the top of Z-order, all other related forms of your applications go on top automatically.
 
—SA
  Permalink  
v7
Comments
Marc A. Brown at 5-May-11 14:06pm
   
You always provide such good answers. Nicely explained.
SAKryukov at 5-May-11 14:19pm
   
Thank you very much, Marc.
--SA
EdMan196 at 5-May-11 14:24pm
   
I can only repeat what Marc has said ;P - My 5
SAKryukov at 5-May-11 14:25pm
   
Thank you so much,
--SA

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

  Print Answers RSS
0 Maciej Los 350
1 OriginalGriff 283
2 Nguyen.H.H.Dang 230
3 Sergey Alexandrovich Kryukov 230
4 Peter Leow 195


Advertise | Privacy | Mobile
Web02 | 2.8.140709.1 | Last Updated 5 May 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid