Results 1 to 7 of 7

Thread: [RESOLVE] DAdd TreeView Node On The Fly

  1. #1

    Thread Starter
    Addicted Member g-mie's Avatar
    Join Date
    Jan 2004
    Location
    EarTh
    Posts
    212

    Resolved [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 Attached Files
    Last edited by g-mie; Nov 5th, 2007 at 08:34 AM.

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Add TreeView Node On The Fly

    What does txtParentKey contain?

  3. #3

    Thread Starter
    Addicted Member g-mie's Avatar
    Join Date
    Jan 2004
    Location
    EarTh
    Posts
    212

    Re: Add TreeView Node On The Fly

    Input Relative Key via txtParentKey

  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    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

  5. #5

    Thread Starter
    Addicted Member g-mie's Avatar
    Join Date
    Jan 2004
    Location
    EarTh
    Posts
    212

    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

  6. #6
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    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.

  7. #7

    Thread Starter
    Addicted Member g-mie's Avatar
    Join Date
    Jan 2004
    Location
    EarTh
    Posts
    212

    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
  •  



Click Here to Expand Forum to Full Width