$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 > Menu Events in C#

Menu Items C# Events of Menus WinForms Control

Kettic Menu WinForms Control contains various MenuItem Events for C# developers to apply this control to their applications. They need to handle the events of the menu items to add, set, and remove the menus they are designing. In this article, we are going to demonstrate how to use the key C# events for the KetticMenuItem object.

Significant Events for KetticMenuItem

The Click event is the most significant event for KetticMenuItem object and is fired when the user chooses the menu item or builds the shortcut key. The other two events, ChangeToggleState and ChangedToggleState, are able to display check marks and will be fired when applying removing a check mark from the KetticMenuItem object.

How to Handle the ChangeToggleState event in C#.NET

To handle the ChangeToggleState event, pass a ChangeStateEventArgs parameter with properties for NewValue, OldValue and Cancel. The NewValue and OldValue are ToggleState enumeration types with values of Intermediate, On and Off. When the Cancel is enabled, the checkbox will not change state and the ToggleStatedChanged event will not fire.
C# code for handling the ChangeToggleState event in .NET project

void ketticMenuItem2_ChnageToggleState(object sender, ChangeStateEventArgs args)
{
if (args.NewValue == Kettic.WinForms.Enumerations.ToggleState.Indeterminate)
{
args.Cancel = true;
}
}

How to Handle ChangedToggleState event in C#.NET

The ChangedToggleState event will be fired while the checkbox state changing. Pass the ChangedStateEventaArgs parameter to this event handler with one of the ToggleState properties of On, Off or Intermediate.
C# code for handling the ChangedToggleState event

void ketticMenuItem2_ChangedToggleState(object sender, ChangedStateEventArgs args)
{
MessageBox.Display(args.ToggleState.ToString());
}

How to Handle KetticMenuComboItem Events in C#.NET

KetticMenuComboItem passes EventArgs with ComboBoxElement property and the C# code below will apply the ComboBoxElementChangedIndexSelected event to get the value of combo box that currently selected.

void Form1_Load(object sender, EventArgs e)
{
ketticMenuComboItem1.ComboBoxElement.ChangedIndexSelected +=
new Kettic.WinForms.UI.Data.PositionChangedEventHandler(ComboBoxElement_ChangedIndexSelected);
}

void ComboBoxElement_ChangedIndexSelected (object sender, EventArgs e)
{
KetticListDataItem item = (sender as KetticDropDownListElement).SelectedItem as KetticListDataItem;
MessageBox.Display(item.Text);
}

KetticMenuContentItem

To handle the KetticMenuContentItem events, assign it to the Kettic Menu control. The C# code below demonstrates how to handle the event and attach a Click button item.

KetticMenuContentItem buttonItem = new KetticMenuContentItem();
KetticButtonElement button = new KetticButtonElement();
button.Text = "OK";
button.Click += new EventHandler(button_Click);
buttonItem.ContentElement = button;
ketticMenu1.Items.Add(buttonItem);
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