|
-
Jul 22nd, 2003, 07:11 AM
#1
Thread Starter
Hyperactive Member
MouseDown On TreeView
What I am trying to achieve is when I right-click on a Node in the treeview control a menu will appear giving options to remove the current node, add a child node etc..
I am using the following to get the selected node:
VB Code:
Me.tvwCompanies.SelectedNode = Me.tvwCompanies.GetNodeAt(New System.Drawing.Point(e.X, e.Y))
That in itself is not a problem, but if I right click on a space in the treeview control and not a node I get an error (which is understandable because I haven't actually selected a node).
Is there anyway I can find out whether I have right-clicked on a node or not and if not then don't do anything otherwise show the menu.
Regards,
Matt.
-
Jul 25th, 2003, 01:59 AM
#2
I think GetNodeAt returns nothing if there is no node at the designated point. Or you could just catch the error in a Try..Catch block and work from there.
-
Jul 25th, 2003, 04:07 AM
#3
Thread Starter
Hyperactive Member
Thanks
I did end up using Try Catch, which is what seemed sensible, but I just wondered if there was a "nice" way.
Thanks for you time.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|