Dynamically populating a form with 'standard' panels
-
Sunday, April 08, 2012 10:35 PM
Hello All,
I am looking to have an 'opening form' where by a user selects different options via checkboxes, e.g. Server1, Server2, Server3 etc.. and then hits a button which opens a subform.
For the sake of example, the user checks Server1 and Server3 options on the opening form via the checkboxes, and hits open.
I would like the second form to open, and adjust in size and content based on the checkboxes selected previously. The Server1 etc.. options all have the same layout of buttons, controls etc.
How would I go about dynamically populating this subform with the controls content of Server1 and Server3? Could I create a 'standard' panel with all the controls necessary, and then somehow replicate it for each option but change the name of the controls based on the previous checkbox, and repeat it for each different option selected?
Say this where possible, how could I control the layout of where each panel was placed, so that i couldn't have any more than 3 panels on one row?
I am open to suggestions as to how this could be achieved, c# examples would be awesome :)
Please ask if you want more explanation!
Thanks for reading!
Peter
All Replies
-
Monday, April 09, 2012 12:29 AM
Hi Peter,
I believe ,for your scenario that right option is to put the similar controls inside user control for server 1.....server 'n' and then you can just load the user control as is in the new forms or wherever you want them to.That's the way to go.This way you won't have to worry about arrangement of controls and perhaps this strategy would take care of the major portion of the codebase too.
I hope this helps.
Many Thanks,
BR,
JollyWagoner
-
Monday, April 09, 2012 4:00 AM
Are you talking about WinForm here?
If it is then you can take a look of this
http://www.philosophicalgeek.com/2008/12/12/an-easy-stack-layout-panel-for-winforms/
http://www.codeproject.com/Questions/218702/winforms-printing-all-the-contents-of-a-panel-in-C
chanmm
- Marked As Answer by Bob ShenMicrosoft Contingent Staff, Moderator Monday, April 23, 2012 2:42 AM
-
Tuesday, April 10, 2012 12:10 PMHi both,
Thanks for your replies.
@Jollywagoner, That sounds like the sort of solution I am after, what do you think is the best way of approaching this? What form of user control do you think? And how would I implement this in visual studio?
@chanmm, Yes windows forms please, The stack layout panel answers my second question, so thats useful, thanks. But the second is to do with printing out a document, I guess the same question applies as I asked Jolly, any ideas?
Thanks again,
Peter -
Thursday, April 12, 2012 3:59 AMModerator
Hi Namethemonkey,
How's it going? Do you have any updates about the previous issue?
Bob Shen [MSFT]
MSDN Community Support | Feedback to us

