Skip to content

How To Get Control Events in Custom Control Back To Parent Form

alan

Asked Oct 21, 2010, 6:30 AM EDT1 answer
Share
LinkedInX
This was easy in VC++ I could use GetParent() and then SendMessage(). I have no idea how to do this in c# and have searched all over.
I have a Form1.cs project
I have a TreeViewCustomControl project
I have a treeview1 control on the user control panel.
I can get the treeview1 doubleclick events in the custom control class fine but don't know how to let the form know which node (text) was double clicked.
I can also get doubleclick events for custom control in form1 class but this doesn't help me either because this lies under the treeview1.
How to get text of treeview1 nodes which are doubleclicked inside the form1.cs?

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    I figured it out.
    I tried this before but must have done it wrong.
    inside the control class:
    private void treeView1_MouseDoubleClick(object sender, MouseEventArgs e)
    {
    base.OnMouseDoubleClick(e); // calls same event for control in form1.cs
    }
    0