ImageList

F

FBxiii

Hi.

I have finally created a treeview control that seems to be working now.

My next question is, how do I create a new image list and populate it with
the images to display on the treeview?

I have tried ImageList2.Add("FileName") but get an Object Required error.

Any ideas?

Cheers,
Steve.
 
R

Rob Parker

Hi again,

There are several steps in this:

1. Add an ImageList control to your form (from the More Controls list in
the toolbox - where you found the treeview control). You can either use the
default name (which will be "ImageListn", where n is the next available
number for controls on your form), or rename it to something more
meaningful. The standard prefix for an imagelist control is "ils", so your
name could be "ilsMyImagesForTreeView", for example.

2. Right-click the imagelist control to access its properties. Use the
General tab to select the size of your icon images (they must all be the
same size). Use the Images tab to add your images to the imagelist;
remember the index number for each image; that's how you associate it with a
particular node (via the image and selectedimage parameters in the Nodes.Add
method (as described in Doug Steele's recent post to another thread of
yours).

3. The key step - in your treeview control's properties (Generaltab),
select or enter the name of your imagelist control. Now, when you populate
your treeview control, you can include the image and selectedimage indexes
to determine the icons shown.

I guess it would be possible to set up the imagelist programmatically, using
similar syntax to filling a treeview, but I've never done so. If I wanted
to do that, I would go and search in the MSDN library (I gave you a URL for
that in a previous post) to determine the exact syntax required.

HTH,

Rob
 
F

FBxiii

Thanks for the help (again!)

I had managed to work out the imagelist control but read somewhere it was
better to do it using 'Hard code'. I am quite happy to use the control
though as I think it is easier to see the objects in the list.

Cheers,
Steve.
 

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