Hello,
I can't find the event when i click on a radContextMenu.
I added few items and from my radListControl after right click on radListControl item and choose my radContextMenu item i want to catch my click event.
i only can see that radContextMenu has different events like DropDownClosed, DropDownClosing, DropDownOpened and DropDownOpenning
I can't find the event when i click on a radContextMenu.
I added few items and from my radListControl after right click on radListControl item and choose my radContextMenu item i want to catch my click event.
i only can see that radContextMenu has different events like DropDownClosed, DropDownClosing, DropDownOpened and DropDownOpenning
3 Answers, 1 is accepted
0
Hi Pogy,
Thank you for writing.
The RadContextMenu itself does not have Click event. Generally, you should subscribe to its items Click events. For example, you can initialize the context menu like this:
More information about this can be found in the following article: RadMenuItem Events.
Let me know if you have additional questions.
Regards,
Dimitar
Telerik
Thank you for writing.
The RadContextMenu itself does not have Click event. Generally, you should subscribe to its items Click events. For example, you can initialize the context menu like this:
RadContextMenu contextMenu;
public
Form1()
{
InitializeComponent();
contextMenu =
new
RadContextMenu();
RadMenuItem menuItem1 =
new
RadMenuItem(
"Item 1"
);
menuItem1.ForeColor = Color.Red;
menuItem1.Click += menuItem1_Click;
contextMenu.Items.Add(menuItem1);
}
void
menuItem1_Click(
object
sender, EventArgs e)
{
RadMessageBox.Show(
"Menu item 1 clicked"
);
}
More information about this can be found in the following article: RadMenuItem Events.
Let me know if you have additional questions.
Dimitar
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Rawad
Top achievements
Rank 2
answered on 09 Jul 2014, 06:31 AM
Hello Dimitar
Hope you are good.
I have 2 questions:
1- I'm trying to catch events of item in contextmenu, but in your solution, we must add the radcontextmenu by code, but if we add it by design, how to catch events of the item.
2- how to disable or enable items inside contextmenu, when we attach the contextmenu to the treeview. for example in my contextmenu i have the following items. 1- New 2- Edit 3- Delete, When the user Right Click on a node1 I want to disable 2- Edit , 3- Delete, but when the user Right click on node2 , I want to enable them and disable 1-New , etc . . .
Thanks
Hope you are good.
I have 2 questions:
1- I'm trying to catch events of item in contextmenu, but in your solution, we must add the radcontextmenu by code, but if we add it by design, how to catch events of the item.
2- how to disable or enable items inside contextmenu, when we attach the contextmenu to the treeview. for example in my contextmenu i have the following items. 1- New 2- Edit 3- Delete, When the user Right Click on a node1 I want to disable 2- Edit , 3- Delete, but when the user Right click on node2 , I want to enable them and disable 1-New , etc . . .
Thanks
0
Hi Rawad,
Thank you for writing.
1. It does not matter how you have added the items. You can subscribe to their event the same way in both cases. When you are adding items design time the code for them is automatically added for you. However you can still access them as usual. For example if you add some items your designer generated code will look like the attached image. Then you can subscribe to the Click event as usual:
2. You can enable or disable the any item by setting its Enabled property to before showing the menu:
I hope this helps. Should you have any other questions do not hesitate to ask.
Regards,
Dimitar
Telerik
Thank you for writing.
1. It does not matter how you have added the items. You can subscribe to their event the same way in both cases. When you are adding items design time the code for them is automatically added for you. However you can still access them as usual. For example if you add some items your designer generated code will look like the attached image. Then you can subscribe to the Click event as usual:
public
Form1()
{
InitializeComponent();
radMenuItem1.Click += radMenuItem1_Click;
}
void
radMenuItem1_Click(
object
sender, EventArgs e)
{
}
2. You can enable or disable the any item by setting its Enabled property to before showing the menu:
radMenuItem1.Enabled =
false
;
I hope this helps. Should you have any other questions do not hesitate to ask.
Dimitar
Telerik
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.