Edit this page

RadMenuItem Events

Usually you will handle the events of the objects that make up a menu, not the RadMenu itself.

RadMenuItem Events

The key event for the RadMenuItem object is the Click event, which is fired when the user selects the menu item or presses the associated shortcut key. If the menu item is designed to display check marks, then the ToggleStateChanging and ToggleStateChanged events fire when a check mark is applied to or removed from the RadMenuItem object.

  • ToggleStateChanging: Passes a StateChangingEventArgs parameter with properties for NewValue, OldValue and Cancel. Both NewValue and OldValue are ToggleState enumeration types with values Indeterminate, On and Off. If the Cancel argument is set to true the check-box does not change its state and the ToggleStatedChanged event does not fire.

Handling the ToggleStateChanging event

void radMenuItem2_ToggleStateChanging(object sender, StateChangingEventArgs args)
    if (args.NewValue == Telerik.WinControls.Enumerations.ToggleState.Indeterminate)
        args.Cancel = true;

Private Sub radMenuItem2_ToggleStateChanging(ByVal sender As Object, ByVal args As StateChangingEventArgs)
    If args.NewValue = Telerik.WinControls.Enumerations.ToggleState.Indeterminate Then
        args.Cancel = True
    End If
End Sub

  • ToggleStateChanged: This event fires when the check-box state changes between one of the ToggleState enumeration values of On, Off or Indeterminate. The StateChangedEventaArgs passed to this event handler contain the ToggleState property.

Handling the ToggleStateChanged event

void radMenuItem2_ToggleStateChanged(object sender, StateChangedEventArgs args)

Private Sub radMenuItem2_ToggleStateChanged(ByVal sender As Object, ByVal args As StateChangedEventArgs)
End Sub

RadMenuComboItem Events

For the RadMenuComboItem, you will probably want to work with the events of the embedded ComboBoxElement property. The example below uses the ComboBoxElement.SelectedIndexChanged event to get the currently selected combo box value.

Handling the SelectedIndexChanged event of RadMenuComboItem

void Form1_Load(object sender, EventArgs e)
    radMenuComboItem1.ComboBoxElement.SelectedIndexChanged += new Telerik.WinControls.UI.Data.PositionChangedEventHandler(ComboBoxElement_SelectedIndexChanged);
void ComboBoxElement_SelectedIndexChanged(object sender, EventArgs e)
    RadListDataItem item = (sender as RadDropDownListElement).SelectedItem as RadListDataItem;

Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
    AddHandler radMenuComboItem1.ComboBoxElement.SelectedIndexChanged, AddressOf ComboBoxElement_SelectedIndexChanged
End Sub
Private Sub ComboBoxElement_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
    Dim item As RadListDataItem = TryCast((TryCast(sender, RadDropDownListElement)).SelectedItem, RadListDataItem)
End Sub


Handle the events for the control assigned to RadMenuContentItem.ContentElement, not the content item itself. In the example below an event handler is attached to the Click event of a button.

Handling events for controls embedded in RadMenuContentItem

RadMenuContentItem buttonItem = new RadMenuContentItem();
RadButtonElement button = new RadButtonElement();
button.Text = "OK";
button.Click += new EventHandler(button_Click);
buttonItem.ContentElement = button;

Dim buttonItem As New RadMenuContentItem()
Dim button As New RadButtonElement()
button.Text = "OK"
AddHandler button.Click, AddressOf button_Click
buttonItem.ContentElement = button

See Also