TreeView Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Boni

    #1

    TreeView Question

    Dear all,

    is it possible to implement a tree node so that double click on the tree
    node does some operation and double click on "+" of this tree node only
    expands tree without doing this operation. Unfortunately I only know
    GetNodeAT(x,y), which don't differentiate "+" from the node.

    Thanks in advance for your help.

    Boni




  • Crouchie1998

    #2
    Re: TreeView Question

    It is something like:

    Protected Overrides Sub OnDoubleClick(B yVal e As System.EventArg s)

    If SelectedNode.Ge tType() Is GetType(TreeNod e) Then
    CType(SelectedN ode, TreeNode).Open( )
    End If

    End Sub

    Public Sub Open()
    System.Diagnost ics.Process.Sta rt([Node Name Here])
    End Sub

    -------------------

    The above code is out of a control I created that extends the TreeView. The
    '[Node Name Here]' is obviously the selected node name

    You'll have to play around with the code slightly, but it should give you a
    general idea.

    Crouchie1998
    BA (HONS) MCP MCSE


    Comment

    • Carlos J. Quintero [.NET MVP]

      #3
      Re: TreeView Question

      There is no easy way to differentiate the "+" from the remaining zone, but
      anyway the "+" requires only a single click, not a double click. The code
      below shows how to override the WM_LBUTTONDBLCL K event:

      Protected Overrides Sub WndProc(ByRef m As System.Windows. Forms.Message)

      Const WM_LBUTTONDBLCL K As Integer = &H203

      Dim bHandled As Boolean = False

      Select Case m.Msg

      Case WM_LBUTTONDBLCL K
      Me.OnDoubleClic k(EventArgs.Emp ty)
      bHandled = True

      End Select

      If Not bHandled Then
      MyBase.WndProc( m)
      End If

      End Sub


      --
      Best regards,

      Carlos J. Quintero

      MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
      You can code, design and document much faster.
      Free resources for add-in developers:
      MZ-Tools has a single goal: To make your everyday programming life easier. As an add-in to several Integrated Development Environment (IDEs) from Microsoft, MZ-Tools adds new menus and toolbars to them that provide many new productivity features.


      "Boni" <oilia@nospam > escribió en el mensaje
      news:enOD%23KIf FHA.3960@TK2MSF TNGP14.phx.gbl. ..[color=blue]
      > Dear all,
      >
      > is it possible to implement a tree node so that double click on the tree
      > node does some operation and double click on "+" of this tree node only
      > expands tree without doing this operation. Unfortunately I only know
      > GetNodeAT(x,y), which don't differentiate "+" from the node.
      >
      > Thanks in advance for your help.
      >
      > Boni
      >
      >
      >
      >[/color]


      Comment

      • Boni

        #4
        Re: TreeView Question

        Dear Carlos,
        I am sorry, but I don't understand how to use your code.
        As you wrote, I do need a double click for a "remaining zone", but only a
        single click for +.
        Thanks a lot,
        Boni
        "Carlos J. Quintero [.NET MVP]" <carlosq@NOSPAM sogecable.com> schrieb im
        Newsbeitrag news:OOnkLeIfFH A.2384@TK2MSFTN GP15.phx.gbl...[color=blue]
        > There is no easy way to differentiate the "+" from the remaining zone, but
        > anyway the "+" requires only a single click, not a double click. The code
        > below shows how to override the WM_LBUTTONDBLCL K event:
        >
        > Protected Overrides Sub WndProc(ByRef m As System.Windows. Forms.Message)
        >
        > Const WM_LBUTTONDBLCL K As Integer = &H203
        >
        > Dim bHandled As Boolean = False
        >
        > Select Case m.Msg
        >
        > Case WM_LBUTTONDBLCL K
        > Me.OnDoubleClic k(EventArgs.Emp ty)
        > bHandled = True
        >
        > End Select
        >
        > If Not bHandled Then
        > MyBase.WndProc( m)
        > End If
        >
        > End Sub
        >
        >
        > --
        > Best regards,
        >
        > Carlos J. Quintero
        >
        > MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
        > You can code, design and document much faster.
        > Free resources for add-in developers:
        > http://www.mztools.com
        >
        > "Boni" <oilia@nospam > escribió en el mensaje
        > news:enOD%23KIf FHA.3960@TK2MSF TNGP14.phx.gbl. ..[color=green]
        >> Dear all,
        >>
        >> is it possible to implement a tree node so that double click on the tree
        >> node does some operation and double click on "+" of this tree node only
        >> expands tree without doing this operation. Unfortunately I only know
        >> GetNodeAT(x,y), which don't differentiate "+" from the node.
        >>
        >> Thanks in advance for your help.
        >>
        >> Boni
        >>
        >>
        >>
        >>[/color]
        >
        >[/color]


        Comment

        • Carlos J. Quintero [.NET MVP]

          #5
          Re: TreeView Question

          You must derive a class TreeViewEx from Treeview and put that code inside.

          What I meant is that since "+" requires only a single click, likely users
          won´t double-click on that zone, you I would not worry about that, but if
          you really want, the TVM_HITTEST message will tell you:

          http://msdn.microsoft.com/library/de...vm_hittest.asp

          --
          Best regards,

          Carlos J. Quintero

          MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
          You can code, design and document much faster.
          Free resources for add-in developers:
          MZ-Tools has a single goal: To make your everyday programming life easier. As an add-in to several Integrated Development Environment (IDEs) from Microsoft, MZ-Tools adds new menus and toolbars to them that provide many new productivity features.


          "Boni" <oilia@nospam > escribió en el mensaje
          news:usxhiOJfFH A.3944@TK2MSFTN GP10.phx.gbl...[color=blue]
          > Dear Carlos,
          > I am sorry, but I don't understand how to use your code.
          > As you wrote, I do need a double click for a "remaining zone", but only a
          > single click for +.
          > Thanks a lot,
          > Boni[/color]


          Comment

          • Boni

            #6
            Re: TreeView Question

            Dear Carlos, Dear Crouchie1998,
            Thank you,
            "Boni" <oilia@nospam > schrieb im Newsbeitrag
            news:enOD%23KIf FHA.3960@TK2MSF TNGP14.phx.gbl. ..[color=blue]
            > Dear all,
            >
            > is it possible to implement a tree node so that double click on the tree
            > node does some operation and double click on "+" of this tree node only
            > expands tree without doing this operation. Unfortunately I only know
            > GetNodeAT(x,y), which don't differentiate "+" from the node.
            >
            > Thanks in advance for your help.
            >
            > Boni
            >
            >
            >
            >[/color]


            Comment

            Working...