开发者

How to create collapsible panels as custom controls in Winforms?

The closest I can think of using is the GroupBox contro开发者_如何学Gol which has a custom drawing at the top identifying the panel.

Is it doable? I have done independent custom controls like buttons, sliders, color pickers, but not totally sure if this sort of drawing can be done on a GroupBox?

I would need the grouping of a GroupBox or a TabPanel.

Are there any alternatives on the net that I can use?

Just exploring the alternatives before I start doing it.


A technique we used was to create multiple panels docked to the top of a frame and set their height to zero. Then when we wanted to display a panel we set its height correctly. Winforms automatically reflows other panels to accommodate the new one.

You can also create a recurring timer to trigger every few hundred milliseconds that increases the panel's height by a few pixels until it reaches full size. This creates a nice animation of the panel expanding into place.


See how others have done this. Code Project's got a bunch. Try searching there.

I used this one a while ago and liked it:

Windows XP style Collapsible Panel Bar


Why not just create a composite control? Something to the effect of.. 2 panels or a label and a panel or whatever suits your needs. Drawing it wouldn't be all that difficult but seems overly complicated for your desired functionality. Am I completely missing the mark?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜