How to place a form inside a panel


Author
Message
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
I have a main form which has a menu on it and menu items call various forms. When the called form displays, it can display on top of the menu. How do I avoid this. Probaly a panel is the solution as a placeholder but am not sure how to place the called from into the panel. Also, does this have any implication for MDI forms .
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Gerard,



I believe your main form need to be an MDI and then each form will be a child of the MDI form.



Trent has posted some sample on how to create your own MDI form here, just look in the forum for "MDI". Also the StrataFlix sample have some code on how to create your own MDI form and how to call your other forms and make them child of the MDI parent.

Edhy Rijo

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.3K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
You'll have to experiment with this, but you should be able to do this via code. I.e. something like this:



//-- Instantiate form, set it to be NOT top level.

MyChildForm frm = new MyChildForm();

frm.TopLevel = false;



//-- Add this to the form's collection of controls.

this.Controls.Add(frm);



//-- You still have to call show...

frm.Show();




A couple of things to note:

- You have to set the TopLevel property to false, otherwise you'll get a "Top-level control can't be added to a control" exception.

- You must also show the added form, or you won't see anything.

- You can add it to other containers. E.g. a panel, a splitter control's panel, etc.

- The form will be movable and sizable if configured.



Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.3K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
As Edhy stated, an MDI setup is also valid. Not sure which is what you want, but now you have options. BigGrin
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Hi. Thanks for all your replies. I am having difficulty 'adding' my form to the panel. I thought  I could do something like:

this.themedPanel1.Add(mycalledForm);

but there is not an Add method for themedPanel1 that I can see at least.  Is there another way of doing this


Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
ok. Did a bot of digging around and can now add the form to a panel:

themedPanel1.Controls.Add(smaForm);


Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.3K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Yep, that's the it! Glad your getting it going!
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search