New to Telerik UI for WinForms? Download free 30-day trial

Customize the control context menu

When the RadCommandBar control is right clicked, a context menu enlisting the strips in the control together with Customize menu option (allowing to customize the strips) is being shown. This context menu is being populated by the time of its opening and in order to customize its items, you should do that from within the DropDownOpening event of this context menu. Here is how to subscribe to this event and how add your custom item and how to remove the Customize option:

radCommandBar1.CustomizeContextMenu.DropDownOpening += new CancelEventHandler(CustomizeContextMenu_DropDownOpening);

AddHandler RadCommandBar1.CustomizeContextMenu.DropDownOpening, AddressOf CustomizeContextMenu_DropDownOpening

void CustomizeContextMenu_DropDownOpening(object sender, CancelEventArgs e)
    //add custom item
    RadMenuItem myItem = new RadMenuItem("MyItem");
    //remove the customize menu option
    for (int i = 0; i < radCommandBar1.CustomizeContextMenu.Items.Count; i++)
        if ( radCommandBar1.CustomizeContextMenu.Items[i].Text == "Customize...")

Private Sub CustomizeContextMenu_DropDownOpening(sender As Object, e As System.ComponentModel.CancelEventArgs)
    'add custom item
    Dim myItem As New RadMenuItem("MyItem")
    'remove the customize menu option
    For i As Integer = 0 To RadCommandBar1.CustomizeContextMenu.Items.Count - 1
        If RadCommandBar1.CustomizeContextMenu.Items(i).Text = "Customize..." Then
        End If
End Sub

Figure 1: CustomizeContextMenu

WinForms RadCommandBar CustomizeContextMenu Example

In this article