Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / June 2005

Tip: Looking for answers? Try searching our database.

TreeView Question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Boni - 29 Jun 2005 09:15 GMT
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 - 29 Jun 2005 09:40 GMT
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
Carlos J. Quintero [.NET MVP] - 29 Jun 2005 09:49 GMT
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

Signature

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 all,
>
[quoted text clipped - 6 lines]
>
> Boni
Boni - 29 Jun 2005 11:16 GMT
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
> 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
[quoted text clipped - 30 lines]
>>
>> Boni
Carlos J. Quintero [.NET MVP] - 29 Jun 2005 14:37 GMT
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/platfor
m/commctls/treeview/messages/tvm_hittest.asp


Signature

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
Boni - 30 Jun 2005 16:58 GMT
Dear Carlos, Dear Crouchie1998,
Thank you,
> Dear all,
>
[quoted text clipped - 6 lines]
>
> Boni

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.