Use events - when mouse is clicked on "control C", you should handle it in parent.
Main Topics
Browse All TopicsVery simple,
I have a user control (A) that contains a list of a user controls (B), that each B contains a user control (C).
I have a context menu in A that needs manage B controls (add, remove, select etc.)
The problem is when I right click on a C control, the grandparent (A) doesn't know a bout it.
Even if I manage to call it by subscribing it's methods (methods of A) to C events (E.g. MouseUp) ,
I get the mouse point related to C and not to A, thus while trying to find the child with
GetChildAtPoint() I get the wrong child.
What's the best way to handle this?
How do I forward the mouseUp caught by a grandson control to it's granparent?
Thanks!
Udi.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
"I get the mouse point related to C and not to A, thus while trying to find the child with
GetChildAtPoint() I get the wrong child."
Use the PointToScreen() and PointToClient() functions.
From (C), convert the click point to Screen coords using PointToScreen(). Then you can pass that value to (A) (thru events or however you want to do it) which will convert it to Client coords using PointToClient(). Once it is in client coords you can then use the GetChildAtPoint() function.
But if you have a nesting like you describe, A --> B --> C, I'm not sure you can get a (C) control from (A) via GetChildAtPoint(). You may only get (B) controls from the function...not sure there.
Business Accounts
Answer for Membership
by: PeterFearnPosted on 2006-02-07 at 03:57:51ID: 15891316
I'm guessing you're talking about windows forms?
his); // or however you plan to handle the right click
The reason I ask, is that in web forms you can call RaiseBubbleEvent in the child control, and handle it by overriding OnBubbleEvent on the Page
You could do somthing like this in the control when you right click
UdibsControl control = Parent.Parent as UdibsControl; // if udibscontrol is the type of your user control
control.HandleRightClick(t