Skip to main content
Email Password   helpLost your password?

Demo

Demo

Introduction

Yesterday, I was thinking the best way to solve a particular situation (specific actions derived logically from one) was a split button. Searching and searching on MSDN produced no results, so I was perplexed: no split button in .NET? No, there isn't. The strange thing is that a StripSplitButton (or something like that) exists, that is, the split button equivalent for the ToolStrip. Probably, not being a standard control for the system, they though not to include the control, because it was easy to simulate its functionality with images, and that's what I did.

Using the code

The control is very easy to use. Anyway, this is the step-by-step how-to-do:

  1. Include SplitButton.cs and SplitButton.designer.cs in your project.
  2. Load the assembly in the toolbox of Visual Studio, or just insert a Button control in your form, and then change the type from Button to SplitButton.

    [Updated: Oct '06] You can stop here, default images for split states will be used by the control, or you can follow next steps to customize split images.

    Optional:

  3. Add an ImageList to your form (or control or whatever) and set the ImageList property of the SplitButton to this ImageList.
  4. Add images you want to the ImageList for the SplitButton splitter side statuses: Normal, Hover, Clicked, Disabled, Focused.
  5. Now, have a look at the property windows for the SplitButton, go to "Split Button Images" category, and simply select an image for each status from the list box of images (the ones in the ImageList of the SplitButton).
  6. Now, you can set some suggested options: TextAlign to MiddleLeft, ImageAlign to MiddleRight, and TextImageRelation to TextBeforeImage. You're done.

Now you can set some custom options for the SplitButton, a brief description follows:

In addition to this, there are two events:

Conclusion

It's only a simple control, I know, but it could be useful in my opinion.

So, that's all, I think. I hope you'll find it useful, bye!

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralHow should i do to get this dropdown fuction to the web style dropdownlist 's effect? Pin
tanglbin
20:06 18 Nov '09  
GeneralGreat work. Pin
Nate Shoffner
16:44 23 Jul '09  
GeneralThank you ! Pin
JackChen1987
16:51 19 Jul '07  
GeneralRe: Thank you ! Pin
dubbele onzin
9:52 9 Nov '07  
QuestionEvent to handle a subitem being clicked? Pin
CdnProgrammer
5:08 19 Jul '07  
AnswerRe: Event to handle a subitem being clicked? Pin
Gladstone
6:31 19 Jul '07  
NewsSlightly more professional SplitButton [modified] Pin
VB Guy
16:43 24 Jun '07  
GeneralRe: Slightly more professional SplitButton Pin
Gladstone
4:53 25 Jun '07  
GeneralRe: Slightly more professional SplitButton Pin
VB Guy
5:37 25 Jun '07  
GeneralRe: Slightly more professional SplitButton Pin
Gladstone
7:38 25 Jun '07  
GeneralRe: Slightly more professional SplitButton Pin
CdnProgrammer
12:37 18 Jul '07  
GeneralPrevent right-click context menu Pin
AutoDeveloper
4:49 31 Oct '06  
GeneralRe: Prevent right-click context menu [modified] Pin
Gladstone
7:26 31 Oct '06  
GeneralBackground image stays enabled Pin
golan.barnov
5:44 21 Oct '06  
GeneralRe: Background image stays enabled Pin
Gladstone
6:17 21 Oct '06  
GeneralRe: Background image stays enabled Pin
golan.barnov
6:38 21 Oct '06  
GeneralRe: Background image stays enabled Pin
Gladstone
14:57 21 Oct '06  
GeneralRe: Background image stays enabled Pin
Gladstone
15:07 21 Oct '06  
GeneralRe: Background image stays enabled Pin
golan.barnov
16:31 22 Oct '06  
GeneralA much easier way without programming. Pin
Nice Life
22:25 26 Sep '06  
GeneralRe: A much easier way without programming. Pin
leggan
22:41 26 Sep '06  
GeneralRe: A much easier way without programming. Pin
Nice Life
23:03 26 Sep '06  
GeneralRe: A much easier way without programming. Pin
leggan
23:13 26 Sep '06  
AnswerRe: A much easier way without programming. Pin
tCodex
9:29 14 Nov '06  
GeneralRe: A much easier way without programming. Pin
Adadurov
11:16 24 Feb '08  


Last Updated 25 Oct 2006 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2009