Jalal Eddin
Top achievements
Rank 1
Jalal Eddin
asked on 08 Sep 2010, 09:21 AM
Dear All,
I'm facing a problem in using RadContextMenu, my form contains three charts and i want to assign the same menu for all of them so i used The RadContextMenu property to assign the menu, but my problem is when the user pick any choice from the menu, how can i know on which chart did the user click ?? the sender contains rad menu control not the chart control.
Thank you
I'm facing a problem in using RadContextMenu, my form contains three charts and i want to assign the same menu for all of them so i used The RadContextMenu property to assign the menu, but my problem is when the user pick any choice from the menu, how can i know on which chart did the user click ?? the sender contains rad menu control not the chart control.
Thank you
7 Answers, 1 is accepted
0
Accepted
Hi Jalal Eddin,
Thank you for writing.
Currently, in order to determine which control has been clicked, you should track down the element that is under the mouse when the context menu is opened. Please consider the following code snippet that demonstrates this behavior:
I will add this case as a feature request in our issue tracking system and we will consider implementing a more intuitive behavior in a future release.
I have updated your Telerik points for this request. If there is anything else I can assist you with, do not hesitate to contact me.
Sincerely yours,
Stefan
the Telerik team
Thank you for writing.
Currently, in order to determine which control has been clicked, you should track down the element that is under the mouse when the context menu is opened. Please consider the following code snippet that demonstrates this behavior:
public
Form1()
{
InitializeComponent();
radContextMenu1.DropDownOpened +=
new
EventHandler(radContextMenu1_DropDownOpened);
}
Point p;
Control currentControl;
void
radContextMenu1_DropDownOpened(
object
sender, EventArgs e)
{
p = ((RadContextMenu)sender).DropDown.Location;
TraverseControls(
this
);
}
public
void
TraverseControls(Control ctrl)
{
foreach
(Control control
in
ctrl.Controls)
{
if
(control == ctrl.GetChildAtPoint(ctrl.PointToClient(p)) && control.Controls.Count > 0)
{
currentControl = control;
TraverseControls(control);
}
else
if
(control == ctrl.GetChildAtPoint(ctrl.PointToClient(p)))
{
currentControl = control;
}
}
}
I will add this case as a feature request in our issue tracking system and we will consider implementing a more intuitive behavior in a future release.
I have updated your Telerik points for this request. If there is anything else I can assist you with, do not hesitate to contact me.
Sincerely yours,
Stefan
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Joy
Top achievements
Rank 1
answered on 03 Dec 2014, 05:30 PM
All,
I'm currently facing a similar need as Jalal from the original post 4 years ago. I'm currently needing to determine the appropriate CheckedListBox the mouseDown event originated from.
Has this request been implemented yet or do I need to try the suggested code below?
Thanks!
I'm currently facing a similar need as Jalal from the original post 4 years ago. I'm currently needing to determine the appropriate CheckedListBox the mouseDown event originated from.
Has this request been implemented yet or do I need to try the suggested code below?
Thanks!
0
Hello Joy,
This is not implemented in the suite, however, I can offer an even easier solution to access the caller control with a single line of code:
If we receive more requests to include the control in the event information, we will consider it in a future release.
Regards,
Stefan
Telerik
This is not implemented in the suite, however, I can offer an even easier solution to access the caller control with a single line of code:
void
radContextMenu1_DropDownOpening(
object
sender, CancelEventArgs e)
{
Control parent =
this
.GetChildAtPoint(
this
.PointToClient( Control.MousePosition));
}
If we receive more requests to include the control in the event information, we will consider it in a future release.
Regards,
Stefan
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
Joy
Top achievements
Rank 1
answered on 04 Dec 2014, 03:20 PM
Stefan –
The provided line of code did not work for me. The parent Control variable is picking up the RadGroupBox instead of the CheckedListBox. I’m not sure if it’s because I dynamically created the CheckedListBox or it’s just an issue with layered controls. Please see my sequences of layered controls from Bottom to Top.
RadGroupBox > Panel > CheckedListBox
Thank You.
The provided line of code did not work for me. The parent Control variable is picking up the RadGroupBox instead of the CheckedListBox. I’m not sure if it’s because I dynamically created the CheckedListBox or it’s just an issue with layered controls. Please see my sequences of layered controls from Bottom to Top.
RadGroupBox > Panel > CheckedListBox
Thank You.
0
Hello Joy,
That is correct, this method will return just the first level control. The following thread notes how you can get the topmost one: http://stackoverflow.com/questions/7508943/getchildatpoint-method-is-returning-the-wrong-control.
I hope this helps.
Regards,
Stefan
Telerik
That is correct, this method will return just the first level control. The following thread notes how you can get the topmost one: http://stackoverflow.com/questions/7508943/getchildatpoint-method-is-returning-the-wrong-control.
I hope this helps.
Regards,
Stefan
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
Joy
Top achievements
Rank 1
answered on 05 Dec 2014, 04:16 PM
Thanks Stefan for the help!
In theory this should work, but in my case it gets to the Panel level and then returns null. It doesn't see the CheckedListBox for some reason. May be because it dramatically created. I'll just stick with the original solution for now.
Thanks again.
In theory this should work, but in my case it gets to the Panel level and then returns null. It doesn't see the CheckedListBox for some reason. May be because it dramatically created. I'll just stick with the original solution for now.
Thanks again.
0
Hi Joy,
Thank you for writing back.
I have logged a feature request in our feedback portal. Please refer to the following feedback item. For the time being you should continue to use the first workaround proposed in this thread.
Your Telerik Points have been updated for this request.
If you have any additional questions, please let me know.
Regards,
Peter
Telerik
Thank you for writing back.
I have logged a feature request in our feedback portal. Please refer to the following feedback item. For the time being you should continue to use the first workaround proposed in this thread.
Your Telerik Points have been updated for this request.
If you have any additional questions, please let me know.
Regards,
Peter
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.