Hi,
I have problem - I am making program where I have more forms (these forms are derived from Form2) in form (in panel in Form1). All forms derived from Form2 are activate. And by clicking outside forms derived from Form2 not deactivates these forms - as it is normally (when are forms free on your desktop). But I need normal behavior of these forms - so that was activated only one form derived from Form2. Most likely I can not do other thing than deactivated forms manually. But the method Deactivate() can not applicable. What do you advise? Thanks for any help!
More forms in panel (this panel is in Form1)
Page 1 of 19 Replies - 1380 Views - Last Post: 05 June 2012 - 02:24 PM
Replies To: More forms in panel (this panel is in Form1)
#2
Re: More forms in panel (this panel is in Form1)
Posted 04 June 2012 - 02:13 PM
I advise you get someone else to translate your question into English.
What you have here makes little sense.
Perhaps a screen capture of your program with comments about what is wrong and an example from a program that does what you want.
What you have here makes little sense.
Perhaps a screen capture of your program with comments about what is wrong and an example from a program that does what you want.
#3
Re: More forms in panel (this panel is in Form1)
Posted 04 June 2012 - 09:11 PM
Into the panel I added Form2 - using this.panel1.Controls.Add(p); (p is new Form2) These Forms2 are creates by a user - number of Forms2 there may be infinite. All Forms2 in panel are activated. (If you do not understand what I mean - I mean method Activate() - later method Deactivate()) . By clicking outside these Formy2 these Formy2 are not deactivated (Method Deactivate()). Manualy I can not use method Deactivate() - I can use only method Activate(). Now - what I must do? Thanks.
#4
Re: More forms in panel (this panel is in Form1)
Posted 05 June 2012 - 05:38 AM
What you are describing doesn't make sense.
You can't add a form to a panel. It will generate an error like this one.
You can't add a form to a panel. It will generate an error like this one.
#5
Re: More forms in panel (this panel is in Form1)
Posted 05 June 2012 - 05:53 AM
#6
Re: More forms in panel (this panel is in Form1)
Posted 05 June 2012 - 11:45 AM
Samms, on 05 June 2012 - 05:53 AM, said:
Then for correctness, you should not be using the Form control. You should be using the ContainerControl. That way you don't have to be playing games with the TopLevel property.
#7
Re: More forms in panel (this panel is in Form1)
Posted 05 June 2012 - 12:37 PM
OK - how exactly should I do it? Thanks.
#8
Re: More forms in panel (this panel is in Form1)
Posted 05 June 2012 - 01:19 PM
The same way forms are built up using:
You would do the same:
Don't like to handwrite your controls? Use the VS forms designer to create a dummy form and then cut and paste the code from InitializeComponent(), as well as any event handlers you may have defined.
var form = new Form(); form.Controls.Add(...); :
You would do the same:
var container = new ContainerControl(); container.Controls.Add(...); :
Don't like to handwrite your controls? Use the VS forms designer to create a dummy form and then cut and paste the code from InitializeComponent(), as well as any event handlers you may have defined.
#9
Re: More forms in panel (this panel is in Form1)
Posted 05 June 2012 - 01:24 PM
Or even easier, just right click on your project, Add>User Control... and then design away visually.
A UserControl derives from ContainerControl. Additionally, it should have the correct activation/deactivation behavior without you having to play tricks with Activate() and Deactivate() calls explicitly.
A UserControl derives from ContainerControl. Additionally, it should have the correct activation/deactivation behavior without you having to play tricks with Activate() and Deactivate() calls explicitly.
#10
Re: More forms in panel (this panel is in Form1)
Posted 05 June 2012 - 02:24 PM
A UserControl is definitely the way to go. These tutorials should help you out.
Bulding an application - Part 1
Building an application - Part 2
Bulding an application - Part 1
Building an application - Part 2
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|