View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Robert Bruce[_2_] Robert Bruce[_2_] is offline
external usenet poster
 
Posts: 108
Default TreeView Image List

Roedd <<mark wedi ysgrifennu:


There's the question... how do I work with an image list and
images... I couldn't seem to find it in the available controls,
though they are both there for dimensioning in the code.


Right-click on your controls toolbox to add a new control. From the list,
pick Microsoft ImageList (might be version 5 or 6 depending on which version
of VB you have installed). You can then add this control to your form.
Select the control once it is on your form's surface and set its properties
(including adding images) via the (Custom)[...] section of the properties
window.

Once you have added some images, you will find that you can't bind your
treeview to your imagelist at design time. I suspect that this is because
the two controls were not designed to be used with MSForms (and/or vice
versa). So, you'll have to bind at run time -

Private Sub UserForm_Initialize()
Set Me.TreeView1.ImageList = Me.ImageList1
Me.TreeView1.Nodes.Add , , , "My Node", 1, 2
Me.TreeView1.Nodes.Add , , , "My Other Node", 1, 2
'etc...
End Sub

You should be aware that to use this control in Office (except for Access)
you will need a design time licence for every machine it runs on. In other
words, you are not allowed to distribute Excel apps built with the treeview
and/or the imageview control.

--
Rob

http://www.asta51.dsl.pipex.com/webcam/

This message is copyright Robert Bruce and intended
for distribution only via NNTP.
Dissemination via third party Web forums with the
exception of Google Groups and Microsoft Communities
is strictly prohibited and may result in legal action.