TreeView Image List

G

Guest

Hi.

I'm basically new to TreeView, though I have tried it before, a long time ago.

I found a short example about adding nodes, referencing them to parents,
etc...

I see that you can add images to the nodes, but in order to do it, you need
to first have an imagelist associated with the treeview.

Which in turn means that you have to instantiated an image list, and
populated it with images.

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.

Thanks for any help with this.
 
R

Robert Bruce

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.
 
G

Guest

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.



Thanks for telling me about that.

I use two machines here at work... one has Visual Basic 6, and the other
does not. The one that does not have VB6 does have MS Access 2000. Is that
why the treeview and imagelist controls are available on the machine without
VB?

Question... how would one be supposed to know that distributing Excel apps
with the treeview and imagelist is inappropriate, when it is available and
works from Excel, without any warnings about illegality? I didn't know.
(and haven't done it yet).

Mark
 

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