|
-
Jul 5th, 2000, 10:01 AM
#1
Thread Starter
New Member
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
-
Jul 5th, 2000, 10:24 AM
#2
PowerPoster
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
-
Jul 5th, 2000, 10:50 AM
#3
Thread Starter
New Member
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.
-
Jul 5th, 2000, 10:53 AM
#4
Thread Starter
New Member
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
-
Aug 25th, 2000, 05:09 AM
#5
New Member
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
-
Aug 25th, 2000, 05:19 AM
#6
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
-
Aug 25th, 2000, 05:33 AM
#7
New Member
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
-
Aug 25th, 2000, 06:31 AM
#8
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|