Results 1 to 3 of 3

Thread: MouseDown On TreeView

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2000
    Location
    Chesterfield, UK
    Posts
    298

    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:
    1. 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.

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2000
    Location
    Chesterfield, UK
    Posts
    298

    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
  •  



Click Here to Expand Forum to Full Width