Click here to Skip to main content
12,755,516 members (40,053 online)
Rate this:
Please Sign up or sign in to vote.
See more: VB VB.NET
How to connect two forms? Suppose I have two forms - if I write 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 21:31pm
Updated 4-May-11 21:43pm
OriginalGriff 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?
Legor 5-May-11 3:25am
Unclear, be more precise.
Keith Barrow 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 5-May-11 13:14pm
I have some idea what is should be, at least part of it -- please see my answer.
SAKryukov 5-May-11 14:26pm
Very unclear indeed, but I got some idea, please see how I answered.

1 solution

Rate this: bad
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[^].

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.

Marc A. Brown 5-May-11 14:06pm
You always provide such good answers. Nicely explained.
SAKryukov 5-May-11 14:19pm
Thank you very much, Marc.
EdMan196 5-May-11 14:24pm
I can only repeat what Marc has said ;P - My 5
SAKryukov 5-May-11 14:25pm
Thank you so much,

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

    Print Answers RSS
Top Experts
Last 24hrsThis month

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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100