[2005] Changing contents of window via button
Hi,
I posted a similar post earlier, but think I phrased it badly and too specifically using panels.
I have some (12) buttons on the left hand side of my windows form, and would like them to change the controls presented on the right hand side of the form. On each page there will be at least 20 individual controls, so I need a way of editing them easily.
I know one method would be to simply have 12 different forms with each button closing the previous one and opening another one with the different controls, but that seems a bit silly.
It's also been suggested that I have 12 (11 non visible) panels all in the same place and adjust their visible property. Problem with this is it's a very long winded way and it's not easy to edit the sets of controls easily.
I'm wondering if modules or classes would help, but I'm new to the software so am not really sure... Thanks!
Re: [2005] Changing contents of window via button
Would not a TabControl be appropriate, with each set of controls on their own TabPage? This sounds like exactly the sort of situation that the TabControl was created for. Note that you can change the appearance of a TabControl to a degree. The tabs can be displayed on different sides and they can be displayed a buttons. Note also that there are some display issues with the TabControl in some of the less common configurations. If you try and have issues then the VisualStyles component in my signature will fix them.
Re: [2005] Changing contents of window via button
Hi there,
I've used a tabpanel, but the buttons (now on the left thanks to your advice) are grey & ugly, and the text is written vertically, like a tab. I'd like to have XP style buttons with icons.
Ideally, I'd be able to get rid of the tabs on the tabpanel, and just control which tab is displayed by a custom button. Any ideas?
Thanks for the help, and your signature is the most useful I've ever seen!
Re: [2005] Changing contents of window via button
Hmmm... you may not be able to get exactly what you want out of a TabControl. You should probably just use multiple Panels as you suggested in the first place. It's actually very easy to handle in the designer. You simply drag as many Panels as you need onto the form, making sure to add each one to the form and not another Panel. Once they're all on the form you select them all and go to the Properties window to set the Location and Size properties for all at the same time. Now you'll have them all stacked on top of each other. If you right click on the top Panel, i.e. the only one you can see, and select "Send to Back" then it will be sent to the bottom of the stack. You can then edit the controls on the next Panel. You can do this repeatedly to cycle through all the Panels in the stack. Alternatively you can go to the Properties window and select the Panel you want from the drop-down list at the top. This will create a selection border for the Panel even if it is covered by othe Panels. You can right-click on that border and select "Bring to Front" and that Panel will be brought to the top of the stack and you can edit its controls. If you ever need to add another Panle you simply click the title bar of the form and then double-click the Panel in the Toolbox. Another Panel is added to the form, which you can then set the Location and Size for manually in the Properties window. Just make sure you don't drag Panels in the design window because if you do there's every chance that you'll end up nesting one inside another and then it can become fiddly to clean things up, although by no means impossible.
Re: [2005] Changing contents of window via button
Ah, yes the problem with using that method before was that I'd accidentally nested the panels within each other, causing plenty of problems!
Thanks for the help :)