$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
Buttons Control for WinForms UI Tutorial
Add Split Button to C# Window Forms applications with the WinForms UI button control
Home > WinForms UI Controls > User Manual > Split Button in C#

Split Button - C# WinForms UI Design

The WinForms UI Button Component provides the split buttons, which are menu like interface model within a button that can be placed on a form in .NET development. Developers can customize all the items on the Split Button to perform an action while being clicked. All the items also have their own items, which allow developers to configure the button label text by change the Text properties. There are some difference between a standard button and Split Button. Split Button could display the drop down items while being clicked, which make it impossible to handle the Click event. However, it works directly with the events of the items, and the following tutorial shows how to use the split button items.
The Drop Down Button and Split Button have similar appearance. But there is an important programmatic distinction. On Split Button control, the property of Default Item indicates the item whose Click event will be triggered. If you want a button that does something when clicked as well as when a selection is made from the menu, the Split Button is the preferable control.

Related Button UI for C# Windows Forms Applications

How to Use the Split Button Items

There is an item collection of the Split Button, which defines the menu items displaying while clicking the Split Button. To add items to your new button, drag and drop a Split Button control from the Toolbox to the Forms that you are designing.

How to Add Items at Design Time in the UI

  1. To add menu items at Design Time, click on the Items property, then click the ellipsis button to launch the Element Collection Editor.
  2. Click the arrow next to the Add button to add items to the menu. A variety of items are available for the collection.
  3. After adding a Menu Item to the collection, it will appear in the list on the left side of the dialog.
  4. Click the Menu Item to edit its properties in the corresponding property grid on the right of the dialog.
  5. In the property of grid, you will find many of the standard control properties available.

Properties Available

  • Text property is able to specify the text appearing on the item
  • Tool Tip Text will appear when we move the mouse to hovers over an item.
  • Child Collection of Items, each Menu Item contains a child collection of Items, which allows developers to create menu hierarchies in the Split Button.
  • Image, associate an image to an item or associate a standard Image List component to the Split Button. The Image Index or Image Key property is for the item.
  • Popup Direction determines the direction in which the child items of a Menu Item will be displayed and can be left, right, up or down.
  • Two Columns and Right Column Items, display child items in two columns.
  • Check on Click toggles a check mark next to a Menu Item.

How to Add Items at Run Time in C# Code

The below C# code shows how to add items to Split Button in C# code at run time and add a Menu Item to the Split Button. Create item hierarchies in C# code by adding new Menu Item objects to the Items collection of your existing Menu Item.

private void Form1_Load(object sender, EventArgs e)
{
MenuItem myMenuItem = new MenuItem();
myMenuItem.Text = "My New Item";
myMenuItem.Click += new EventHandler(myMenuItem_Click);
SplitButton1.Items.Add(myMenuItem);
}

void myMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show((sender as MenuItem).Text);
}

How to Display Images with Items

With the split button controls, images as well as text can be displayed on the menu items.
  1. To add an image to the menu item in WinForms project, switch to the Image property of the Menu Item,
  2. Click the ellipsis button to launch the Select Resource dialog.
  3. Choose an image file from a project resource file or from the local hard drive.

How to Use the Click Event

  1. Open the Properties window of the Windows Form designer
  2. Locate the Menu Item in the drop down list to handle the Click event of Menu Items.
  3. Click the events button, and double click the Click event to generate an event handler.
  4. Fill in the details with the handling C# code for the event.
UI Controlsfor Windows Forms
.NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI Design
WinForms UI Controls