TreeView Question

  • Thread starter Thread starter Boni
  • Start date Start date
B

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
 
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
 
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
 
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
 
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/d...rm/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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top