By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,990 Members | 2,138 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,990 IT Pros & Developers. It's quick & easy.

Treeview NodeClick

P: n/a
I seem to miss then treeview NodeClick
How can i check if a node is clicked when it is selected?

Nov 21 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Rob,

Do you mean something as this?

Beneath this is exactly what you ask, this is shows when it is selected, so
clicked)
\\\
Private Sub TreeView1_AfterSelect _
(ByVal sender As Object, ByVal e As _
System.Windows.Forms.TreeViewEventArgs) _
Handles TreeView1.AfterSelect
Dim mynodeText As String = e.Node.Text
End Sub
///
\\\
Private Sub TreeView1_Click(ByVal sender _
As Object, ByVal e As System.EventArgs) _
Handles TreeView1.Click
Dim myNodeText As String = _
DirectCast(sender, TreeView).SelectedNode.Text
End Sub
///
I hope this helps?

Cor
Nov 21 '05 #2

P: n/a
Hi Cor,

i have tried that before but:
This will also trigger if i click someware else on the treeview.

"Cor Ligthert" <no**********@planet.nl> schreef in bericht
news:et**************@TK2MSFTNGP09.phx.gbl...
Rob,

Do you mean something as this?

Beneath this is exactly what you ask, this is shows when it is selected, so clicked)
\\\
Private Sub TreeView1_AfterSelect _
(ByVal sender As Object, ByVal e As _
System.Windows.Forms.TreeViewEventArgs) _
Handles TreeView1.AfterSelect
Dim mynodeText As String = e.Node.Text
End Sub
///
\\\
Private Sub TreeView1_Click(ByVal sender _
As Object, ByVal e As System.EventArgs) _
Handles TreeView1.Click
Dim myNodeText As String = _
DirectCast(sender, TreeView).SelectedNode.Text
End Sub
///
I hope this helps?

Cor

Nov 21 '05 #3

P: n/a
* "rob willaar" <lw****@xs4all.nl> scripsit:
I seem to miss then treeview NodeClick
How can i check if a node is clicked when it is selected?


Add a handler to the treeview's 'MouseUp' event and use the treeview's
'GetNodeAt' method to get the node under the cursor.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #4

P: n/a
"rob willaar" <lw****@xs4all.nl> wrote in message
news:41***********************@news.xs4all.nl...
Hi Cor,
i have tried that before but:
This will also trigger if i click someware else on the treeview.


Hi Cor,

The Click event is raised when you click on any item in the treeview,
including the parent node you're trying to expand. In the end I ended up
using the DoubleClick event - and the users seem to be reasonably happy with
that.

HTH
Dany.
Nov 21 '05 #5

P: n/a
Rob,

The second sample does, however the first in my opinion not?

Where is my mistake?

However that first fires after the click when that is on a select of a node.

When you want first to select and than do an extra click, than I think that
you have to go to the solution from Dany. (Because there should be a distict
between a click and a double click).

Cor
Nov 21 '05 #6

P: n/a
Hi All,

Herfried got the solution to create the NodeClick event.
The code is like follows to call OpenMenu:
Private Sub tvMain_MouseUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles tvMain.MouseUp

Dim pt As Drawing.Point

pt.X = e.X

pt.Y = e.Y

Dim tn As TreeNode = tvMain.GetNodeAt(pt)

OpenMenu(GetTVMenukey(tn))

End Sub

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> schreef in bericht
news:2o************@uni-berlin.de...
* "rob willaar" <lw****@xs4all.nl> scripsit:
I seem to miss then treeview NodeClick
How can i check if a node is clicked when it is selected?


Add a handler to the treeview's 'MouseUp' event and use the treeview's
'GetNodeAt' method to get the node under the cursor.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.