Results 1 to 6 of 6

Thread: treeview context menu

  1. #1

    Thread Starter
    Hyperactive Member MetallicaD's Avatar
    Join Date
    Feb 2001
    Location
    Tallahassee, FL
    Posts
    488

    treeview context menu

    Hello.. I have a treeview that has an associated context menu.. When i right click on the treeview, the menu pops up.. correct!! however, if i right click on an element in the treeview that is currently not selected, it gets highlighted but the treeview still indicates that the .selectednode is the one that was previously highlighted...

    it sounds like the selectitem event is not finishing before the contextmenu popup event fires..

    any suggestions?

    thanks
    -Matt
    [vbcode]
    '*****************************
    MsgBox "MCD :: [email protected]", vbInformation + vbOKOnly, "User"
    '*****************************
    [/vbcode]

  2. #2

    Thread Starter
    Hyperactive Member MetallicaD's Avatar
    Join Date
    Feb 2001
    Location
    Tallahassee, FL
    Posts
    488
    also..

    is there an property that I can use to get the currently highlighted element instead of the selected one?

    thanks
    -mcd
    [vbcode]
    '*****************************
    MsgBox "MCD :: [email protected]", vbInformation + vbOKOnly, "User"
    '*****************************
    [/vbcode]

  3. #3

    Thread Starter
    Hyperactive Member MetallicaD's Avatar
    Join Date
    Feb 2001
    Location
    Tallahassee, FL
    Posts
    488
    Ok.. i found the same issue on this threat: http://www.dotnet247.com/247referenc...25/129525.aspx

    I used their solution and it works.. now the question is, is this a flaw in the framework? If so, will it be fixed?

    Thanks,
    -mcd
    [vbcode]
    '*****************************
    MsgBox "MCD :: [email protected]", vbInformation + vbOKOnly, "User"
    '*****************************
    [/vbcode]

  4. #4
    Member Vahid's Avatar
    Join Date
    Aug 2002
    Location
    Iran
    Posts
    37
    I dont test your issue, so I write this blind. If there is any mistake, forgive me.
    I dont think about this as a flaw, because this has easy workarounds, simply handle the Click event and show the context menu by code instead of setting the ContextMenu property. Just one line! I don't think treeview has another way to get the selected node (I'm not sure).

    Finally: God bless Metallica, James, Kirk, Lars and JASON

  5. #5

    Thread Starter
    Hyperactive Member MetallicaD's Avatar
    Join Date
    Feb 2001
    Location
    Tallahassee, FL
    Posts
    488
    Vahid... thanks for the reply.. Actually, on that link I provided, there is an easy way to do this with the context menu linked directly to the treeview:

    VB Code:
    1. Private Sub tvwFields_MouseDown(ByVal sender As Object, ByVal e As
    2. System.Windows.Forms.MouseEventArgs) Handles tvwFields.MouseDown
    3. If e.Button = MouseButtons.Right Then tvwFields.SelectedNode =
    4. tvwFields.GetNodeAt(New Point(e.X, e.Y))
    5.  
    6. End Sub

    This works pretty good.. It just changes the selected node to the one you rightclicked on, then the context menu fires

    thanks,
    -matt
    [vbcode]
    '*****************************
    MsgBox "MCD :: [email protected]", vbInformation + vbOKOnly, "User"
    '*****************************
    [/vbcode]

  6. #6
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    i remember programming in vb6 and that error also happened a lot

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