$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
Menus UI WinForms Control
Create attractive menus in C#.NET for your Windows Forms applications
Home > WinForms UI Controls > User Manual > Add or Remove Menus in C#

Adding and Removing Menus Items in C#.NET

Kettic Menu Controls provides easy approaches for the users to add and remove menu items in C#.NET project. Moreover, it is able to add sub menu items to the main menus and populate the drop-down list by using the Kettic MenuComboItems. This Kettic Menu Controls allows the users to customize the menu performance when performing long running operations. To add menus, we need to user the Menu Items collections and to populate the drop-down list, we need to use the ComboBoxElement.

How to Add Menu Items in C#.NET

This section mainly demonstrates how to add main menu items. Kettic Menu control contains the KetticMenu items collection for adding the main menu items to your applications and the KetticMenuItem items collection for adding the sub menu items. The C# code examples below show how to use overload of the KetticMenuItem. The first one applies a parameter-less constructor, assigns the KetticMenuItem Text property and finally adds the menu item to the KetticMenu Items collection. The second one uses a single string Text parameter, includes and adds menu items all at one time. And the third one applies a constructor with a second object Tag parameter storing any arbitrary data in.
C# code for constructing and adding menu items to your C#.NET projects

KetticMenuItem cdItem = new KetticMenuItem();
studentItem.Text = "Students";
ketticMenu1.Items.Add(studentItem);
ketticMenu1.Items.Add(new KetticMenuItem("Student ID"));
int someData = 13001;
KetticMenuItem classItem = new KetticMenuItem("Classes", someData);
ketticMenu1.Items.Add(classItem);

How to Add Sub Menu Items in C#.NET

The approach to add sub menu items is the same as that to add main menu items. This is accomplished by using the KetticMenuItems collection. The C# code below will retrieve a reference to the Student ID and add a few KetticMenuItems to the Student ID menu Items collection. In addition, a Click event handler will be attached to the Height menu item
C# code for adding sub menu items to the main menu

void Form1_Load(object sender, EventArgs e)
{
ketticMenu1.Items.Add(new KetticMenuItem("Student ID"));
KetticMenuItem item = ketticMenu1.Items[0] as KetticMenuItem;
item.Items.Add(new KetticMenuItem("Student Name"));
item.Items.Add(new KetticMenuItem("Reference Student ID"));
KetticMenuItem heightItem = new KetticMenuItem("Height");
heightItem.Click += new EventHandler(menuItem_Click);
item.Items.Add(heightItem);
}

void menuItem_Click(object sender, EventArgs e)
{
KetticMenuItem item = (sender as KetticMenuItem);
MessageBox.Display(item.Text + " was clicked.");
}

How to Add a KetticMenuComboItem

KetticMenuComboItems allows the users to add drop down list to menus. It has no parameters and populates the drop down list by using the ComboBoxElement Items collection.
C# code for adding sub menu items to Height menu

KetticMenuItem bargainItem = new KetticMenuItem("Height");
KetticMenuComboItem comboItem = new KetticMenuComboItem();
comboItem.ComboBoxElement.Items.Add(new KetticListDataItem("123cm"));
comboItem.ComboBoxElement.Items.Add(new KetticListDataItem("135cm"));
comboItem.ComboBoxElement.Items.Add(new KetticListDataItem("147cm"));
bargainItem.Items.Add(comboItem);
ketticMenu1.Items.Add(heightItem);

How to Customize Menu Performance in C#.NET

Kettic Menu controls contains the methods, StartInit() and EndInit(), for suspending layout of the menu to enhance the performance while performing long running operations like loading a number of menu items from a database.
C# code snippet for suspending the layout for performing operations

ketticMenu1.StartInit();
ketticMenu1.EndInit();

How to Remove Menu Items

Kettic Menu controls provides the Remove() or RemoveAt() methods to delete menu items from the items collection. The Remove() method is used to take a reference to the menu item to be removed and the RemoveAt() method is able to take integer position of the item in the collection.
C# code for removing menu items

ketticMenu1.Items.RemoveAt(1);
ketticMenu1.Items.Remove(ketticMenu1.Items[0]);
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