CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 1999
    Location
    California
    Posts
    264

    How to remove a node from treeview control?

    I try to use remove or clear method, but VB always show compile error. Maybe I don't know how to use it. I wonder if anyone can help. Thx.


    Best Regards,

    Kevin Shen
    Best Regards,

    Kevin Shen

  2. #2
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: How to remove a node from treeview control?


    Treeview1.Nodes.Remove index



    Index can be a actual number or the nodes key value

    John G

  3. #3
    Join Date
    Aug 1999
    Location
    California
    Posts
    264

    Re: How to remove a node from treeview control?

    I tried

    Treeview1.Nodes.Remove index

    Treeview1.Nodes.Remove keyvalue




    it doesn't work, compiler show "expected: end of statement"

    Thanks!


    Best Regards,

    Kevin Shen
    Best Regards,

    Kevin Shen

  4. #4
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: How to remove a node from treeview control?


    private Sub Command1_Click()
    Dim intX as Integer
    With TreeView1
    for intX = 0 to 10
    .Nodes.Add , , "a" & intX, "a" & intX
    next

    End With
    TreeView1.Nodes.Remove (2) 'the second node, which is "a1"
    TreeView1.Nodes.Remove ("a9")
    End Sub




    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  5. #5
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: How to remove a node from treeview control?

    You need to replace index with the number of the node you wish to delete or replace keyvalue with the nodes key you used at the time you created the node. Boith the examples below worked fine for me

    TreeView1.Nodes.Remove 100 ' Remove node 100
    Treeview1.Nodes.Remove "ApplX" ' Remove node called ApplX




    John G

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

Featured