Board index » delphi » Treeview with different images

Treeview with different images

I'd like to create a treeview with different bitmap depending of the kind of
object that the node is supposed to represent.
Does anybody knows how to do such a thing a what are the caracteristics the
bitmaps must have ?
Thanks for help.
Robert_Mill...@SPAMCompuserve.com

 

Re:Treeview with different images


Bob,

May I suggest, with all due respect, that the reason you have not up to now got
a reply to your post is that the answer you seek is quite clear from a perusal
of the help file section pertaining to TTreeView?

regards,

Gerhard Groenewald

Quote
Bob wrote:
> I'd like to create a treeview with different bitmap depending of the kind of
> object that the node is supposed to represent.
> Does anybody knows how to do such a thing a what are the caracteristics the
> bitmaps must have ?
> Thanks for help.
> Robert_Mill...@SPAMCompuserve.com

Re:Treeview with different images


In article <#1fCFPqf9GA...@nih2naab.prod2.compuserve.com>, Bob
<Robert_Mi...@Compuserve.com> writes

Quote
>I'd like to create a treeview with different bitmap depending of the kind of
>object that the node is supposed to represent.
>Does anybody knows how to do such a thing a what are the caracteristics the
>bitmaps must have ?
>Thanks for help.

Very easy. I assume you've attached a TImageList to your TTreeView,
and this image list contains one bitmap.

Just add other images to the list, and assign images to nodes by
their index:

TreeView1.Items[0].ImageIndex := 0; //use first image

TreeView1.Items[1].ImageIndex := 1; //use second image...
TreeView1.Items[1].SelectedIndex := 2; //...but use third image when selected

As for image types, I tend to use 16x16, 16-colour icons (not bitmaps as I've
occasionally had transparency problems).

I suggest you look up TTreeView in the help - it has *lots* of useful
properties and methods.

HTH
--
Jeremy Collins
Kansai Business Systems

(return address not altered 'coz I get spammed *whatever* I do!)

Other Threads