TreeView Control (VS2008)

J

John

Hi,

I think it's simple task and I could not figure it out easily ... VB6 treeview used to have a expanded imageindex so it's easy ...

now, in VB.NET, I have folders and items in treeview, for item, I can set the imageindex = selectimageindex to make sure when the item is selected the image will not change.

but there is no way to set the folder easily ... I want to keep the folder's image as "open folder" image regardless if it's selected or not as long as it's expanded and use "close folder" image regardless if it's selected or not as long as it's collapsed.

Could someone help me on this?

Thanks!
John
 
C

Colbert Zhou [MSFT]

Hello John,

We can listen to the TreeView's AfterExpand and AfterCollapse event, in the
event handle, we set the node's image respectively. The following codes
work fine in my side,

Private Sub TreeView1_AfterExpand(ByVal sender As System.Object, ByVal
e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterExpand
e.Node.ImageIndex = 3
End Sub

Private Sub TreeView1_AfterCollapse(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles
TreeView1.AfterCollapse
e.Node.ImageIndex = 0
End Sub

Please have a try and let me know if this helps! If you have any future
questions or concerns, please do not hesitate to let me know.


Best regards,
Colbert Zhou (colbertz @online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
 
C

Colbert Zhou [MSFT]

Hello John,

I am writing to check the status of the issue on your side. Could you
please let me know if the suggestion works for you or not? If you have any
questions or concerns, please feel free to let me know. I will be more than
happy to be of assistance.

Have a great day!

Best regards,
Colbert Zhou ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top