Results 1 to 8 of 8

Thread: Is this microsoft's bug? (treeview with check box)

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    4

    Question

    Hi, I worked over the last weekend to try to figure it out about the treeview with check box. If I have the check box checked without the image, it works. However, if I have a iamge with the node, and have the check box checked in the codes, it did not owrk. I tested it in 3 machines. One with Win95, VB6(SP3) and 2 with VB6(SP4), WINNT. Can anyone try to duplicate it? Thanks.
    ------------------------------
    Private Sub Form_Load()
    Dim mNode As node
    Set mNode = TreeView1.Nodes.Add()
    mNode.Text = "Book"
    mNode.Image = "folder"
    mNode.Checked = True
    End Sub
    --------------------------------

    Bill

  2. #2
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    I think you problem is:

    The Image property is not a path, it's the index of the picture in your ImageList linked to the treeview. Try this:
    Code:
    Private Sub Form_Load() 
    Dim mNode As node 
    Set mNode = TreeView1.Nodes.Add() 
    mNode.Text = "Book" 
    mNode.Image = 1
    mNode.Checked = True 
    End Sub

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    4

    Treeview and check box

    Fox:

    Use either a index or key of the iamge is OK. I use the key of the image in the code. However, it do not solve my problem. The Check box is still not checked.

  4. #4

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    4
    Fox:

    Again, I use the key with name "folder". This is not a path. I should use the key named "horse", which will not confuse you.

    Bill

  5. #5
    New Member
    Join Date
    Aug 2000
    Location
    Italy
    Posts
    9
    I have the same problem !!!

    The code works if you try to check the node with a command button e.g. :

    Code:
    Private Sub Command1_Click()
        Treeview1.Node(1).Checked = True
    End Sub
    but the same doesn't works in the Form_Load Sub
    Mil

  6. #6
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    If you're trying to check the node in the Form_Load event use the Show method of the Form before setting the Checked property.
    Code:
    Private Sub Form_Load()
        Me.Show
        TreeView1.Node("Folder").Checked = True
    End Sub

  7. #7
    New Member
    Join Date
    Aug 2000
    Location
    Italy
    Posts
    9
    Dear Joacim,

    I've tried to implement your code but dosen't works... the only way that I've find to initialize the checked box status is to add a timer and in Form_load write:

    Code:
    Private Sub Form_Load()
        Timer1.Enabled = True
    End Sub
    and in timer1:

    Code:
    Private Sub Timer1_Timer()
        Treeview1.Nodes(1).checked = True
        Timer1.Enabled = False
    End Sub
    Mil

  8. #8
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Thats strange it works for me. Well try moving the code that checkes the node to the Form_Activate event.

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