Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IMPORTANT!!! vb treeview error 1

Status
Not open for further replies.

Goha

IS-IT--Management
May 9, 2002
91
0
0
US
I am converting from a listbox to a treeview

How do i fix the following ....

Form2.Label1.Caption = "Loading parameters for " + vbCrLf + """" + Trim(TreeView1.Nodes(TreeView1.Index)) + """..."

I get the following error:
Run-time error: '343': Object not an array...

Also how do i fine the number of children in a particular node? If that node has no children does it return a 0 or 1?

Thanks in advance
 

To refer to the text use something like...

TreeView1.Nodes.Item(1).Text

and check out the children property of the node object

Good Luck
 
I am trying to get the selected node's name
 
Take that one step furher ...

replace the number 1 withe the selected node's item number as a variable like


TV.Nodes.Item( <selected node's var.> ).Key


thanks
 

AaaHhh, Now I understand what you want. Here is a demo for you...(you will have to add the nodes yourself)

[tt]
Private Sub Command1_Click()

On Error GoTo Command1_ClickError

Dim I As Double, S As String

For I = 1 To TV.Nodes.Count
If TV.Nodes.Item(I).Selected = True Then
S = TV.Nodes.Item(I).Key
Exit For
End If
Next I

If Trim(S) <> &quot;&quot; Then
MsgBox S
Else
MsgBox &quot;No items selected&quot;
End If

Exit Sub
Command1_ClickError:

MsgBox Err.Description

End Sub

[/tt]

Good Luck
 
back to the question on children :

If that node has no children what number does it return ?

 

Small quote from the children property example in vb help...

If TreeView1.SelectedItem.Children > 0 Then

So I would surmise that if there are no children it would return zero

Goo Luck
 
Thanks a lot you have been emensly helpfull

:)I
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top