Articles in this section
Category / Section

How to get the selected radial menuitem in the WinForms RadialMenu?

1 min read

Show the text and index value of Selected RadialMenuItem

In RadialMenu, the text and index value of the selected menu item can be detected by handling the MouseUp event in the RadialMenuItem. The Text and Index property in the RadialMenuItem helps you to specify the text and index value of the RadialMenuItem.

C#

//Hooks the MouseUp event for the whole RadialMenu Items
foreach (Control item in this.radialMenu1.Controls)
{
    if (item is RadialMenuItem)
    {
        (item as RadialMenuItem).MouseUp += Form1_MouseUp;
    }
}
void Form1_MouseUp(object sender, MouseEventArgs e)
{
    if (sender is RadialMenuItem)
    {
        //Gets the index of the selected menu item.
        int index = (sender as RadialMenuItem).Index;
        //Gets the text of the selected menu item
        string selectedText = (sender as RadialMenuItem).Text;
   }
}

VB

'Hooks the MouseUp event for the whole RadialMenu Items
For Each item As Control In Me.radialMenu1.Controls
    If TypeOf item Is RadialMenuItem Then
        AddHandler TryCast(item, RadialMenuItem).MouseUp, AddressOf Form1_MouseUp
    End If
Next item
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs)
    If TypeOf sender Is RadialMenuItem Then
        'Gets the index of the selected menu item.
        Dim index As Integer = (TryCast(sender, RadialMenuItem)).Index
        'Gets the text of the selected menu item
        Dim selectedText As String = (TryCast(sender, RadialMenuItem)).Text
        End Select
    End If
End Sub

 

Text and index value of the selected menuitem

Figure 1: Text and index value of the Selected MenuItem displayed in the Selection log.

 

Samples:

C#: https://www.syncfusion.com/downloads/support/directtrac/140711/ze/RadialMenuSample-839463344

VB: https://www.syncfusion.com/downloads/support/directtrac/140711/ze/RadialMenuSample_VB-280762999

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied