Results 1 to 4 of 4

Thread: Treeview control

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 1999
    Location
    France
    Posts
    90

    Post

    Hi,

    I'm new to using the Treeview control, part of the Windows Common Controls that you find in Project/Components.

    When I add the Treeview control to my form I see 'Sample node' with Windows Explorer like indents, in the control in Design time. But when I run the program, there's no text in the control at all. Could someone tell me how I can make the text appear in run-time, and how I can edit the text?

    Thanks!

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Sure! In disign time it just shows you how the control looks like, but it is up to you to populate the control.
    Here is an example:


    Code:
        Dim xParent As Node  'Parent Node 
        Dim xChild As Node   'Child Node
        Dim i As Integer     'Counter for parent Nodes
        Dim j As Integer     'Counter for Child nodes
        
        With TreeView1
            .LineStyle = tvwRootLines
            .Indentation = 300
            For i = 1 To 5
                Set xParent = .Nodes.Add(, , "Parent" & i, "Parent" & i)
                For j = 1 To 10
                    Set xChild = .Nodes.Add(xParent, tvwChild, , "Child" & i & " to node " & xParent.Text)
                Next
            Next
        End With

    Look in the MSDN library for Node object. It will tell you what it is and how to work with it.
    ------------------

    Serge

    Software Developer
    [email protected]
    [email protected]
    ICQ#: 51055819


    [This message has been edited by Serge (edited 11-19-1999).]

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 1999
    Location
    France
    Posts
    90

    Post

    Thanks for the reply, Serge.

    But I cut and paste the code you give me, and in run-time, I still can't see anything. I didn't change any properties - am I supposed to?

    Here's my exact code:

    Dim xParent As Node 'Parent Node
    Dim xChild As Node 'Child Node
    Dim i As Integer 'Counter for parent Nodes
    Dim j As Integer 'Counter for Child nodes



    Private Sub TreeView1_BeforeLabelEdit(Cancel As Integer)
    With TreeView1
    .LineStyle = tvwRootLines
    .Indentation = 300
    For i = 1 To 5
    Set xParent = .Nodes.Add(, , "Parent" & i, "Parent" & i)
    For j = 1 To 10
    Set xChild = .Nodes.Add(xParent, tvwChild, , "Child" & i & " to node " & xParent.Text)
    Next
    Next
    End With
    End Sub

    Am I doing something wrong?

    Christophe

  4. #4
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    You pasted to the wrong event. Change it to Form_Load event.

    Regards,

    ------------------

    Serge

    Software Developer
    [email protected]
    [email protected]
    ICQ#: 51055819


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