Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Mar 2002
    Location
    Germany, Germany
    Posts
    169
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Using TreeView-Control in UserForm (XP)

    Hello everybody!

    I am creating a userform, that contains a TreeView-Control. It works pretty well. I found out, that it should be possible to assign an icon/picture to the nodes in dependence of the node condition (expanded/collapsed). Unfortunately I did not manage to relate a node to a picture. Does someone have experience with this? Any help will be appreciated. maybe someone out there knows a good recource in the internet on this topic?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Using TreeView-Control in UserForm (XP)

    You must also add an ImageList control to your userform and add the images you need to this control. To do so, click in the Custom property of the ImageList control and click the ... button.
    Add a picture for collapsed nodes and a picture for expanded nodes. You can add several types, if you like.
    Each image will have a unique index (1, 2, 3, ...).
    Next, select the TreeView control, click in the Custom property and click the ... button.
    Set the ImageList property to the name of the ImageList control.
    The Add method of the Nodes property of the TreeView has optional arguments Image (for collapsed) and SelectedImage (for expanded). You can specify the index of a picture in the ImageList control. For example, if you have added two pictures, they will have index 1 and 2. Code would look like this:

    Set nod2 = Me.tvwTree.Nodes.Add(Relative:=nod1, Relationship:=tvwChild, _
    Key:="N2", Text:="Porley", Image:=1, SelectedImage:=2)

    There is a lot of information about these controls on MSDB, but unfortunately many of the pages fail to load at the moment. Try TreeView and ImageList.

  3. #3
    2 Star Lounger
    Join Date
    Mar 2002
    Location
    Germany, Germany
    Posts
    169
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using TreeView-Control in UserForm (XP)

    Hans, thanks again! I really wonder where you have all the knowledge from ;-) At first I could not manage since I could not select the imagelist in the TreeView-Properties. But then I tried via code and it worked.
    Thanks again. Now I will try to work with it.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Using TreeView-Control in UserForm (XP)

    You're correct, the ImageList property in the Custom properties doesn't work correctly on a UserForm (it does work in VB6, and also in Access), so you have to assign the property in code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •