[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1387
  • Last Modified:

Pushing Mouse Events higher up

Hi,

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:
A
 1-
   |-1a
   |-1b
B
C

if I click on b =>

A
B
 1 -
C

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.
0
MsShadow
Asked:
MsShadow
1 Solution
 
Arthur_WoodCommented:
"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.

AW
0
 
MsShadowAuthor Commented:
Appearantly you cannot just give an assist accept so i am giving you a full accept. Wrote my own handler.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now