Pushing Mouse Events higher up

Posted on 2006-04-05
Last Modified: 2008-01-09

I have built a custom usercontrol that displays treeview differently. The first level of the treeview is displayed as a button and the lower levels are displayed as seperate treeviews.

Example: Tree A B C
sublevel A : 1 2 3
sublevel B : 1
sublevel 1 : 1a 1b

so if I click on the button with label A I get to see a tree:

if I click on b =>

 1 -

All of that works perfectly. All the labels and treeviews are generated during the code executing depending on the data that has been given to the control. I've created my event

        mainLabel.Tv.NodeMouseDoubleClick += new TreeNodeMouseClickEventHandler(Tv_NodeMouseDoubleClick);

        void Tv_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
            clickedNodePath = e.Node.FullPath;
            this.RaiseMouseEvent(this, e);

so that when a node is doubleclicked an event is raised so I can get the full path. The only problem is that
RaiseMouseEvent cannot be used. And the whole idea is that my control which contains my extendedlabels fires an event that can be captured by the form that contains the control.

But I don't manage to raise another event. I prefer not to write my own eventhandler since I already have anotherone in my framework that capturs data read events etcetera.
Question by:MsShadow
    LVL 44

    Accepted Solution

    "I prefer not to write my own eventhandler"  well then, you are out of luck - the only way to accomplish what you are describing is to have the original event handler, raise a new event, which can the  be handled by the form which is hosting your User Control.  Cascading the events back uup the hosting hierarchy is a fairly common scenario, and there is no other way to accomplish it, other than passing the events up the hosting chain.

    Form1 hosts control1 which in turn hosts control1a - control1a raises an event which is handled by control1, which in turn raises a new event, which is then handled by Form1.

    LVL 19

    Author Comment

    Appearantly you cannot just give an assist accept so i am giving you a full accept. Wrote my own handler.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
    Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now