Displaying multiple objects in the same form

ToddHawley4984
ToddHawley4984 used Ask the Experts™
on
Hi,  
I'm currently have a program that consists of a form with several buttons.  Each button loads a different form with its own controls. I would like to change this.  My idea is to only have one form and to use a menustrip. Then of course when i click something in the menu strip the form will be populated with the appropriate controls.  My question:  Is it best to design all the different layouts i want in the designer and then put them in a group box for instance and enable/disable that group box as i need it?  Or should i add and delete the controls i want within the code??  And ideas opinions would be appreciated.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
GrahamSkanRetired
Top Expert 2012

Commented:
I don't see any advantage in the latter. Putting each set of controls in its own group box, and hiding all but the active one is a lot simpler.

I would only advise hiding and showing individual controls if you needed some of the controls to appear in one or more sets.
GrahamSkanRetired
Top Expert 2012

Commented:
'one or more'
should have been
'more than one'

Author

Commented:
Ok thats what i wanted to do but how do you physically deal with that in the designer?  Do you just have them all side by side and then move them to the appropriate location when they load?
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Retired
Top Expert 2012
Commented:
Do you mean how do you populate several group boxes?

You can place them all on the form, but be careful not to nest one inside another. It helps to design with an oversize form so that the boxes can overlap a bit, so that you can select any one. Also you can use Format/Order/Send to Back when you have finished working on one box.

You might want to ensure that the boxes are all the same size and position with code in the Form Load event. That would be simpler than positioning each of the contained controls.

Author

Commented:
Well part of problem is that will have conrols on multiple layout but not in such a way that I can rely on a groupbox. For instance on one page I may have 5 textboxes in a groupbox. Then on another layout I may only need 3 of those textboxes. I've since decided to add all controls for a give layout to a collection and then hide or show then at once. What I don't know how to do is to place them in containers such as a groupbox or panel. I can only place it in one place in the designer and will need to move it with code if I need to use it somewhere else. Is there some object that could be used as a placeholder of sorts?  

Author

Commented:
I feel like I've made my last question difficult to follow.   To make it simpler, How do I, with code, move a textbox that is in a group box or panel to a different groupbox or panel? Unless I am missing something I will have to do this?

Author

Commented:
I'm accepting your solution because i realized a big problem with the idea i was going with and no longer need the last reply answered.  Thanks for the help..

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial