Results 1 to 4 of 4

Thread: Problem TreeView ImageList

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    17

    Problem TreeView ImageList

    Hi, Using VB Net (2005, Access (2003) in Windows Forms. My problem I would like to Select the proper node image. See I have this window form with those 3 principal control namely on the left a treeview, alongside on the right a DataGridView and at the bottom a ListView. Process method: a click on a treenode fill the DataGridView, then a doubleclick in a datarow cell containing data export that data to the ListView control. As I click on the treenode(close folder image), the treenode image change to (open folder image) ok up to here, what I would like is when I have exported the data to the ListView that the already selected treenode image change to (open folder image with a checkmark) and then upon a new treenode selection, the previous treenode selected image change to (close folder image with a checkmark) and this process goes on as long as the ListView as not been empty(clear), when ListView empty then all those folders with checkmark revert back to close folder. In my treeView control I have this OImages control that has 6 images in it’s collection (0 to 5), I have put open folder image with a checkmark and close folder image with a checkmark as 4 and 5 in the image collection, but I don’t know how produce the above effect. I hope I was clear enough. Thank-you in advance.
    Ps: in the treeView control property
    image index = 0
    Selected image index = 2
    Selected image key = none
    Selected image list = none

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Problem TreeView ImageList

    You should use the Tag property of each TreeNode to indicate whether it requires the tick or not. When you add data to the ListView you would set the Tag property of the selected node and change its icon. When that node becomes unselected or selected in future you will test its Tag property. If it's set you would use the appropriate image with the tick, otherwise use the appropriate image without the tick. When you clear the ListView you would also clear all the nodes' Tag properties and reset all the images.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    17

    Re: Problem TreeView ImageList

    Thank you for your quick response, is there a tutorial somewhere about tag property that I could learn from it.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Problem TreeView ImageList

    The Tag property is about as easy as it gets. Whenever you want to know about any type or member you should go straight to the MSDN documentation for that type or member.

    You should have installed the local version when you installed VS/VB so you should be able to just type treenode.tag into the index and go straight to the appropriate topic. If you haven't installed the local version I suggest you remedy that immediately. If you can't for some reason then you've always got the online version. It has even more information but not all of it relevant, so it can be a little more difficult to use. It also lacks the index feature of the local version, but the search feature works well as long as you use logical keywords. Again, treenode.tag will get you where you need to go.

    You should never ask anyone anything without having read the appropriate documentation first. It's fair enough that you didn't know what to do for the original question but as soon as you know what type you're looking for, and particularly what member, the first thing you should be doing is reading the documentation for that type or member. It won't always tell you everything you need to know but you can always look further afield at that point. It will usually give you at least a very good idea though, and often give you all you need.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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