By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,850 Members | 1,005 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,850 IT Pros & Developers. It's quick & easy.

.Add parameter in event handling ???

P: n/a
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
Jul 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Max
> 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
Jul 21 '05 #2

P: n/a
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 ?
-----Original Message-----
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

callingTreeView.GetNodeAt
4. Then, show the context menu at point, provided by MouseEventArgs

.

Jul 21 '05 #3

P: n/a
Max
"serge calderara" <an*******@discussions.microsoft.com> wrote in message
news:0d****************************@phx.gbl...
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
-----Original Message-----
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

Jul 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.