1 Attachment(s)
[RESOLVE] DAdd TreeView Node On The Fly
Hello Gurus...
I want to add TreeView Node on the fly. But error Invalid Object was occur.
How to solve this error?
Or any other idea?
Here my code;
Code:
Private Sub Command1_Click()
TreeView1.Nodes.Add txtParentKey, tvwChild, txtChildKey, txtChildText
'TreeView1.Nodes.Add , , txtChildKey, txtChildText '<--no error for this
End Sub
Private Sub Form_Load()
TreeView1.Nodes.Add , , "a", "aaa"
TreeView1.Nodes.Add "a", tvwChild, "b", "bbb"
TreeView1.Nodes.Add "b", tvwChild, "c", "ccc"
TreeView1.Nodes.Add "c", tvwChild, "d", "ddd"
End Sub
Please refer to my attachment for better info.
Thanks
Re: Add TreeView Node On The Fly
What does txtParentKey contain?
Re: Add TreeView Node On The Fly
Input Relative Key via txtParentKey
Re: Add TreeView Node On The Fly
The relative key accepts a Variant so you can either use a string (key) or an integer (index). However you pass a textbox, not the text. This code works:
TreeView1.Nodes.Add txtParentKey.Text, tvwChild, txtChildKey, txtChildText
Re: Add TreeView Node On The Fly
Joacim Andersson..
Thanks for the info.
I do not know that TextBox and TextBox.Text is not the same.
Thanks alot
Re: [RESOLVE] DAdd TreeView Node On The Fly
Well, the Text property of the TextBox is the default property, so MsgBox(Text1) would give you the same thing as MsgBox(Text1.Text) but that is because MsgBox expects to get a string so the default property of the textbox is used. However a Variant could be set to anything including an object.
Re: [RESOLVE] DAdd TreeView Node On The Fly
Thanks.
It is loud and clear for me now
:D