There are a number of XP like grouping controls on CodeProject and elsewhere:
(Please let me know if I missed someone!)
Thanks to all those who wrote those nice controls. All these controls implement
a number of features, however no single control implements all those features.
So I decided to shamelessly copy their code and "Converge" everything in one!
;-) Also most of them were in C#, so I decided to start with VB.NET for this
one. I used VS 2003 but they should work in VS 2002 also.
Images on the left side of caption.
Animated expand/collapse. Animation can be switched off and the timing can also
be changed. Gives the feeling of gradual fade away.
Drawing in gray if disabled.
Different chevron styles
Can be shown as non-collapsible
Office 2003 line style for the caption
Using the control
You can use it in two ways:
XPanderList control to your form and then drop
controls to the
Or just drop
XPander control to your form.
Most of the properties exposed on the controls are self-explanatory but some
important ones are:
CaptionStyle - Choose a caption style.
makes it look like, Office 2003 flat caption with a line in the end, style.
ChevronStyle - Different chevron styles.
CollapsedHighlightImage - Specify your own bitmaps for chevrons!
(Make sure that you have
ChevronStyle set to
- Image on the left side of the caption.
CanToggle - Is the user allowed to expand/collapse? If
chevrons are not displayed, clicking on the caption does nothing and mouse
cursor remains default.
- Whether to show tool tips or not. Tool tip text is same as the caption text.
- Enable/disable animation.
AnimationTime - How fast/slow (time). Used only if
True. Value 0 behaves as if
- Caption is drawn in this color when hovering.
CaptionHeight - Caption height can be adjusted. All child controls
on this "group" are repositioned automatically with caption height change.
There are more properties for adjusting caption attributes like height, font,
colors and so on.
Collapse() are available on
CollapseAll() are available on
Using the code
The "original articles" do such a good job of explaining the code so I will not
repeat it here. They can be found with the links above.
Points of interest
Note that properties like
CaptionLeftColor of type
(and other properties like it) can be "Reset" using the VS.NET designer. This
is achieved by using the
<Description("Determines the ending (dark) " + _
"color of the caption gradient fill."), _
DefaultValue(GetType(Color), "198, 210, 248"), _
Public Property CaptionRightColor() As Color
To draw disabled strings I use:
ControlPaint.DrawStringDisabled(g, CaptionText, _
m_CaptionFont, capcolor, CaptionRectF, format)
Similarly to draw disabled images I use:
ControlPaint.DrawImageDisabled(g, m_ExpandedImage, _
Me.Width - m_ExpandedImage.Width - 8, 2 + _
Once again since this is more a copy/paste/organize operation then "new code",
all credits go to those who wrote the original controls namely Daren May, Derek
Lakin, Rob Tomson and the people who made TaskVision.
New properties for pane color handling to get a look similar to Longhorn group
PaneBottomRightColor, PaneTopLeftColor, PaneOutlineColor
between image and caption top.
CaptionTextAlign, can be
DrawChevronImage replaced by
you can select
FlatCaptionStyle replaced by
CaptionStyle which can
Reorganized most of the code to make it much more readable.
is also exposed now. Set it to 0 to remove curved captions.
Standard border styles can be used with
BorderStyle. Enable border
drawing by setting
Note: If you are already using version 1.0, you will have to change your
form code to use