.Add parameter in event handling ???

  • Thread starter Thread starter serge calderara
  • Start date Start date
S

serge calderara

Dear all,

I have a class named for Instance "MyClass" which populate
trough an interface a context menu object to the main
application.
The click event on any of the context menu itemm will be
proceed in the myClass event handler. Actally default
event handle has two parameters: Sender and e

Actually the context menu is shown in my main application
when I selecte a tree node object and right click the
mouse button. When the click event is proceed I need to
inform my eventhandler in myClass the selected node when
menu item was clicked.

What is the way to pass to my eventhandler the selected
tree node object?

thnaks for your answer
regards
Serge
 
Dear all,
I have a class named for Instance "MyClass" which populate
trough an interface a context menu object to the main
application.
The click event on any of the context menu itemm will be
proceed in the myClass event handler. Actally default
event handle has two parameters: Sender and e

Actually the context menu is shown in my main application
when I selecte a tree node object and right click the
mouse button. When the click event is proceed I need to
inform my eventhandler in myClass the selected node when
menu item was clicked.

What is the way to pass to my eventhandler the selected
tree node object?
Maybe it is not the best solutuion but:
1. Set ContextMenu property of TreeView to null
2. Handle MouseUp event of TreeView
3. When right button pressed determine selected item by calling
TreeView.GetNodeAt
4. Then, show the context menu at point, provided by MouseEventArgs
 
You did not catch what I was meaning.
I have no problem to pop up the context menu in the tree
view control.

The problem I get is that when I click on item in that
menu, the eventhandler belong to myClass. Whcih means that
the clickevent process will be handle by myClass, but in
order to handle it properly in my case, myClass
eventhandler need to know from where the click as been
generated and in my case I need to pass as a parameter to
my eventhandler a Treenode object.

how can I do that ?
 
serge calderara said:
You did not catch what I was meaning.
I have no problem to pop up the context menu in the tree
view control.

The problem I get is that when I click on item in that
menu, the eventhandler belong to myClass. Whcih means that
the clickevent process will be handle by myClass, but in
order to handle it properly in my case, myClass
eventhandler need to know from where the click as been
generated and in my case I need to pass as a parameter to
my eventhandler a Treenode object.

how can I do that ?
You can't pass the TreeNode object in MenuItem click event arguments.
There are no simple way to do determine tree node where user have clicked in
context menu click event. See my previous post
 
Back
Top