Home All Groups Group Topic Archive Search About
Author
29 Jun 2005 8:15 AM
Boni
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

Author
29 Jun 2005 8:40 AM
Crouchie1998
It is something like:

Protected Overrides Sub OnDoubleClick(ByVal e As System.EventArgs)

If SelectedNode.GetType() Is GetType(TreeNode) Then
    CType(SelectedNode, TreeNode).Open()
End If

End Sub

Public Sub Open()
  System.Diagnostics.Process.Start([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
Author
29 Jun 2005 8:49 AM
Carlos J. Quintero [.NET MVP]
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_LBUTTONDBLCLK event:

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

Const WM_LBUTTONDBLCLK As Integer = &H203

Dim bHandled As Boolean = False

Select Case m.Msg

  Case WM_LBUTTONDBLCLK
   Me.OnDoubleClick(EventArgs.Empty)
   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

Show quoteHide quote
"Boni" <oilia@nospam> escribió en el mensaje
news:enOD%23KIfFHA.3960@TK2MSFTNGP14.phx.gbl...
> 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
>
>
>
>
Author
29 Jun 2005 10:16 AM
Boni
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
Show quoteHide quote
"Carlos J. Quintero [.NET MVP]" <carlosq@NOSPAMsogecable.com> schrieb im
Newsbeitrag news:OOnkLeIfFHA.2384@TK2MSFTNGP15.phx.gbl...
> 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_LBUTTONDBLCLK event:
>
> Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
>
> Const WM_LBUTTONDBLCLK As Integer = &H203
>
> Dim bHandled As Boolean = False
>
> Select Case m.Msg
>
>  Case WM_LBUTTONDBLCLK
>   Me.OnDoubleClick(EventArgs.Empty)
>   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%23KIfFHA.3960@TK2MSFTNGP14.phx.gbl...
>> 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
>>
>>
>>
>>
>
>
Author
29 Jun 2005 1:37 PM
Carlos J. Quintero [.NET MVP]
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/default.asp?url=/library/en-us/shellcc/platform/commctls/treeview/messages/tvm_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:
http://www.mztools.com

Show quoteHide quote
"Boni" <oilia@nospam> escribió en el mensaje
news:usxhiOJfFHA.3944@TK2MSFTNGP10.phx.gbl...
> 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
Author
30 Jun 2005 3:58 PM
Boni
Dear Carlos, Dear Crouchie1998,
Thank you,
Show quoteHide quote
"Boni" <oilia@nospam> schrieb im Newsbeitrag
news:enOD%23KIfFHA.3960@TK2MSFTNGP14.phx.gbl...
> 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
>
>
>
>