Click here to Skip to main content
6,595,444 members and growing! (22,423 online)
Email Password   helpLost your password?
Languages » C / C++ Language » General     Intermediate

XPander Controls Converged

By mkg

WinXP like animated collapsing group box control.
VB, VC7.1.NET 1.1, Win2K, WinXPVS.NET2003, Dev
Posted:21 Aug 2003
Updated:4 Jan 2004
Views:114,532
Bookmarked:33 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
19 votes for this article.
Popularity: 3.91 Rating: 3.06 out of 5
1 vote, 5.3%
1
2 votes, 10.5%
2
2 votes, 10.5%
3
5 votes, 26.3%
4
9 votes, 47.4%
5

Introduction

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.

Feature list

  • 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.
  • Gradient fills.
  • Different chevron styles
  • Can be shown as non-collapsible
  • Tooltips
  • Office 2003 line style for the caption
  • Completely customizable

Using the control

You can use it in two ways:

  1. Drop XPanderList control to your form and then drop XPander controls to the XPanderList control.
  2. 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. FlatLine makes it look like, Office 2003 flat caption with a line in the end, style.
  • ChevronStyle - Different chevron styles. Image, ArrowsInCircle, Triangle.
  • CollapsedImage, ExpandedImage, ExpandedHighlightImage, CollapsedHighlightImage - Specify your own bitmaps for chevrons! (Make sure that you have ChevronStyle set to Image.)
  • Image - Image on the left side of the caption.
  • CanToggle - Is the user allowed to expand/collapse? If False chevrons are not displayed, clicking on the caption does nothing and mouse cursor remains default.
  • ShowTooltips - Whether to show tool tips or not. Tool tip text is same as the caption text.
  • Animated - Enable/disable animation.
  • AnimationTime - How fast/slow (time). Used only if Animated is True. Value 0 behaves as if Animated=False
  • CaptionTextHighlightColor - 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.

Also methods Expand(), Collapse() are available on XPander and ExpandAll(), CollapseAll() are available on XPanderList.

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 Color (and other properties like it) can be "Reset" using the VS.NET designer. This is achieved by using the DefaultValue attribute:

<Description("Determines the ending (dark) " + _ 
    "color of the caption gradient fill."), _
    DefaultValue(GetType(Color), "198, 210, 248"), _
    Category("Caption")> _
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 + _ 
    imageOffsetY, Me.CaptionRightColor) 

Credits

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.

Revision history

  • Ver 1.2
    • New properties for pane color handling to get a look similar to Longhorn group boxes!. PaneBottomRightColor, PaneTopLeftColor, PaneOutlineColor
    • New property ImageOffset between image and caption top.
    • New property CaptionTextAlign, can be Left,Middle or Right
    • New CaptionStyle=WrapAroundLine
    • New ChevronStyle=PlusMinus
  • Ver 1.1
    • DrawChevronImage replaced by ChevronStyle. Currently you can select Image, ArrowsInCircle, Triangle or None.
    • FlatCaptionStyle replaced by CaptionStyle which can be Normal or FlatLine.
    • Reorganized most of the code to make it much more readable.
    • CaptionCurveRadius 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 DrawBorder to True

Note: If you are already using version 1.0, you will have to change your form code to use CaptionStyle and ChevronStyle instead of FlatCaptionStyle and DrawChevronImage.

Happy XPanding!

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

mkg


Member

Occupation: Web Developer
Location: United States United States

Other popular C / C++ Language articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 46 (Total in Forum: 46) (Refresh)FirstPrevNext
GeneralBugs during Mouse Hover Pinmembernetfusion1:09 30 Apr '09  
Generalusing this in visual web developer Pinmemberdualshock030:43 10 Mar '08  
GeneralBug!? help me! Pinmemberscheisse8311:26 12 Sep '07  
Generalprogramming work? PinmemberAlex Niswander8:47 20 Jan '07  
QuestionHeader has a verticle gradient instead of horizontal Pinmemberrwbaker4:02 23 Jun '06  
AnswerRe: Header has a verticle gradient instead of horizontal Pinmemberssamayoa8:06 1 Jul '06  
GeneralRe: Header has a verticle gradient instead of horizontal Pinmemberrwbaker10:18 1 Jul '06  
GeneralThanks a lot! PinmemberCodingWolf15:50 29 Mar '06  
QuestionXPander returning an error in VS.NET 2005 PinmemberNick497821:24 4 Nov '05  
AnswerRe: XPander returning an error in VS.NET 2005 PinmemberbqStony4:14 13 Feb '06  
QuestionExpanding left to right Pinmemberavantip18011:02 7 Oct '05  
AnswerRe: Expanding left to right Pinmembermkg7:35 10 Oct '05  
QuestionI want to ask you How to run it when having error? Pinmembermyphuong24420:24 31 Aug '05  
AnswerRe: I want to ask you How to run it when having error? Pinmembermkg7:37 10 Oct '05  
GeneralRe: I want to ask you How to run it when having error? Pinmembermyphuong24418:00 10 Oct '05  
GeneralXPander Control have error? Pinmembermyphuong24418:29 31 Aug '05  
GeneralRun XPander Controls have errors! Pinmembermyphuong24419:18 29 Aug '05  
AnswerRe: Run XPander Controls have errors! Pinmembermkg8:58 31 Aug '05  
GeneralLittle bug Pinmembertitan_pi86:31 1 Aug '05  
GeneralRe: Little bug Pinmembermkg8:59 31 Aug '05  
GeneralAdding XPander to XPanderList at Runtime Pinmemberslipmat18:10 17 Mar '05  
GeneralTransparent Background Pinmemberromias3:49 4 Feb '05  
GeneralRe: Transparent Background Pinmembermkg6:08 10 Feb '05  
GeneralRe: Transparent Background Pinmembermkg6:26 10 Feb '05  
GeneralRe: Transparent Background Pinmemberromias7:50 10 Feb '05  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 4 Jan 2004
Editor: Nishant Sivakumar
Copyright 2003 by mkg
Everything else Copyright © CodeProject, 1999-2009
Web12 | Advertise on the Code Project