Results 1 to 8 of 8

Thread: [RESOLVED] VS2005: How to determine which node was double-clicked

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2006
    Posts
    39

    Resolved [RESOLVED] VS2005: How to determine which node was double-clicked

    Can anyone help to determine which node was double-clicked when the doubleclick event fires for the treeview?

    I am currently using an imagelist with the treeview nodes. To avoid having the selectedimage display when a node is clicked, I am cancelling the event when the BeforeSelect event fires. Therefore, the node that was just clicked is not the selected node. So I can't use the selectednode property to determine the node that was double-clicked. Any other ideas?

  2. #2
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    Re: VS2005: How to determine which node was double-clicked

    The treeview control has a NodeMouseDoubleClick property that will fire when a node is double clicked

    You can then determine the node by e.Node
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

  3. #3
    Fanatic Member
    Join Date
    Aug 2006
    Location
    In my head
    Posts
    913

    Re: VS2005: How to determine which node was double-clicked

    Here is a quick and dirty to get you started

    Code:
        Private Sub tvwMenu_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles tvwMenu.AfterSelect
            Select Case e.Node.Name
                Case "node1"
                Case "node2"
                Case Else
            End Select
        End Sub
    D
    Platforms of choice: Visual Studio 2005/2008 Professional : Visual Studio 2010 Enterprise : PHP - Notepad++/WAMP

    Please Rate If I helped you.
    Please remember to mark threads as closed if your issue has been resolved.

    Reserved Words in Access | Connection Strings

  4. #4

    Thread Starter
    Member
    Join Date
    Jan 2006
    Posts
    39

    Re: VS2005: How to determine which node was double-clicked

    I suppose I should have looked a bit closer. So many events compared to VB6. Thanks for the help.

    Is there a better way to avoid having the image of a node change when it is selected? Seems odd that feature can't be disabled.

  5. #5
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    Re: VS2005: How to determine which node was double-clicked

    Do you have a selected image? if not, then just make the selected image the same as the other image and therefore it will look the same. I haven't really played with images in treeviews so not really sure, but seems like a viable solution.
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

  6. #6
    Fanatic Member
    Join Date
    Aug 2006
    Location
    In my head
    Posts
    913

    Re: VS2005: How to determine which node was double-clicked

    You can/should use an image list in conjuction with your treeview. It makes it alot easier to control what images are being used when and where with it. ImageList is one of the properties on the treeview control. Under the Collection properties if you add a dummynode you will see that there are different image settings included selectedimage.

    Good Luck!!

    D
    Platforms of choice: Visual Studio 2005/2008 Professional : Visual Studio 2010 Enterprise : PHP - Notepad++/WAMP

    Please Rate If I helped you.
    Please remember to mark threads as closed if your issue has been resolved.

    Reserved Words in Access | Connection Strings

  7. #7

    Thread Starter
    Member
    Join Date
    Jan 2006
    Posts
    39

    Re: VS2005: How to determine which node was double-clicked

    Excellent. Thanks for the help.

  8. #8
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    Re: VS2005: How to determine which node was double-clicked

    I just did some playing around with it and yes... you can set the selectedimage to the same thing as the item image. That way, the image does not change when you select something. I am guessing this is what you are trying to accomplish, if I am wrong please let me know.
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

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