How to get the selected radial menuitem in the WinForms RadialMenu?
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
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