In the visual studio toolbox, all controls are grouped. And you can hide/show certain areas by headers. What control gives similar functionality in my own program? I would like to let the user control what they see on screen. It would be better if the sub-areas could contain text boxes for data entry.
I played around with a treeview but it doesn't seem to be the same. For example i was unable to put the plus on the label itself instead of beside it.
Last edited by Lord Orwell; Jun 5th, 2008 at 09:00 PM.
Create a custom control that inherits from the UserControl class. Then you can override the OnMouseClick event so that when the top area of the panel is clicked, the panel reduces in size, so only that top area of the panel is shown. Use a Boolean value to store whether the Panel is "expanded" or "collapsed".
When you "collapse" the Panel, first store it's Height in a variable (lets call is iExpandedHeight), then change the Panel's Height to, say, 32. Then when you "expand" the panel, simply change the Panel's Height to whatever was stored in the iExpandedHeight variable.
You can then use custom painting to render the top section of the Panel in a different colour to the rest of it, and even paint a plus/minus sign here too.
When you dock the Panel in a Form, any other Panel's you dock underneath it will move to take up space used by the previous Panel when it is collapsed, and move to allow more room when you expand the previous Panel.
You can then place any controls you like inside these Panels, like TextBoxes for example.
Last edited by dom_stapleton; Jun 6th, 2008 at 09:31 AM.
I use Microsoft Visual Basic 2008 Express Edition.
If my post has been helpful, please rate it, unless you don't believe in Karma... which actually I don't!
Here's an example of the basic mechanics of the control...
I've left the OnPaint method blank as this is pretty self-explanatory (this is where you paint the header in a different color and where you draw the plus or minus sign).
I use Microsoft Visual Basic 2008 Express Edition.
If my post has been helpful, please rate it, unless you don't believe in Karma... which actually I don't!
HMM well that looks right but i was hoping it would be somethign i could use at design time. I've never compiled a user control before. Could i add controls at design time with a compiled version of that?
You would have to build upon the example and add a collection class of panels or something so that you could add new items to the collection at run time or in the IDE in your project.
New controls in the VS IDE are not always released for developers to use. Look at the PropertyGrid control. It wasnt made available until .NET after all those years in classic vb.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
any rumors of a service pack for 2008? I am about to go back to 2005. About once every 2 days it seems, i have some kind of issue. Check the game project i am working on in my profile link. Now it's giving me unfound schema warnings. Before that (and a project restore) it was claiming i was declaring my form twice (from IDE-Created code)
Yea but I have only seen 2 really good ones and they were hundreds of dollars. All the others are usually really crappy way off "copies".
Should be some time in the next month or three that SP-1 goes RTM. I wont install the Beta as its a beta and I dont want all the headaches from trying to uninstall a beta and cleaning it up etc.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.