-
September 13th, 2002, 01:43 AM
#1
If no selected nodes in TreeView control
Hi...
When I refere to selected Node in TreeView control, when no selected nodes are, error occurs.. How can I check, is there any selected Node in my TreeView control?
Thank you very much.
-
September 13th, 2002, 04:47 AM
#2
Answer
Hello there...
Well, here is a way to find out if you have any selected nodes in your tree.
For i = 1 To TreeView1.Nodes.Count
If TreeView1.Nodes.Item(i).Selected = True Then
...hold the i somewhere and you have the selected node...
End If
Next
Hope it helped
vvang10
-
September 13th, 2002, 07:29 AM
#3
Ok, thanks a lot...
But probably there must be an easiest way? Probably using some standart method, or comparing like
if TreeControl.Nodes.SelectedItem = Nothing ..... ?????
-
September 13th, 2002, 07:36 AM
#4
Treeview
I think that was the easiest way to find out if you have selected nodes in Treeview.
-
September 13th, 2002, 11:53 AM
#5
Treeview SelectedItem
There is an easier way, browsing for each nodes in a treeview can be a pain if you have a lot of nodes (like it is often the case with treeview), try that code:
Code:
Private Sub Command1_Click()
Dim objNode As Node
'Get the selected node
Set objNode = Me.TreeView1.SelectedItem
'Remove the selection to test
Set objNode = Nothing
'Test if selection
If objNode Is Nothing Then
MsgBox "No selection"
Else
MsgBox "Selection: " & objNode.Text
End If
End Sub
Remove that line afterward
Set objNode = Nothing
JeffB - hope it helps
-
September 15th, 2002, 06:51 AM
#6
Ok! thanks a lot!
-
March 20th, 2013, 09:31 PM
#7
Re: Treeview SelectedItem
Originally Posted by JeffB
There is an easier way, browsing for each nodes in a treeview can be a pain if you have a lot of nodes (like it is often the case with treeview), try that code:
Code:
Private Sub Command1_Click()
Dim objNode As Node
'Get the selected node
Set objNode = Me.TreeView1.SelectedItem
'Remove the selection to test
Set objNode = Nothing
'Test if selection
If objNode Is Nothing Then
MsgBox "No selection"
Else
MsgBox "Selection: " & objNode.Text
End If
End Sub
Remove that line afterward
Set objNode = Nothing
JeffB - hope it helps
NO Me.TreeView1.SelectedItem in Visual Studio 2010.
is there any other way?
-
March 21st, 2013, 11:55 AM
#8
Re: If no selected nodes in TreeView control
This is the VB6 forum, and VS2010 is supported in the .Net forum...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|