Nov 5th, 2007, 02:53 AM
#1
Thread Starter
Addicted Member
[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
Attached Files
Last edited by g-mie; Nov 5th, 2007 at 08:34 AM .
Nov 5th, 2007, 03:50 AM
#2
Re: Add TreeView Node On The Fly
What does txtParentKey contain?
Nov 5th, 2007, 07:37 AM
#3
Thread Starter
Addicted Member
Re: Add TreeView Node On The Fly
Input Relative Key via txtParentKey
Nov 5th, 2007, 08:10 AM
#4
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
Nov 5th, 2007, 08:26 AM
#5
Thread Starter
Addicted Member
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
Nov 5th, 2007, 10:09 AM
#6
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.
Nov 5th, 2007, 11:02 AM
#7
Thread Starter
Addicted Member
Re: [RESOLVE] DAdd TreeView Node On The Fly
Thanks.
It is loud and clear for me now
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