Board index » delphi » Help needed with TreeView icons!

Help needed with TreeView icons!

Hi everybody !
I have a treeview which list the different forms completed for a patient.
I'm trying to put an icon in front of the node's text to show if it is a
locked or unlocked questionnaire (reflecting the state of a boolean field
in the database)
I have tried so many things but I'm at a loss to find the write code or
property.
I'm able to add a particular icon to a given item in the treeview but I
can't figure out how come i can't assign the right icon depending of the
field's value.

Here is a piece of code (a kind of prototype). If I answer no , I get the
open lock, which is correct. But if I answer Yes, I get nothing !

Can someone help me please ? Moreover, you have to consider that I have to
repeat this to different given items in my treeview (working with the item
indexes...)
Thanks in advance !!
Lina

procedure TForm1.Button1Click(Sender: TObject);
var
        i:integer;
begin
TreeView1.StateImages:= ImageList1;
if MessageDlg('Est-ce que c''est verrouill ?',
    mtConfirmation, [mbYes, mbNo], 0) = mrYes then
    TreeView1.Items[3].StateIndex:= 0
else
        TreeView1.Items[3].StateIndex:= 1;

end;

It works only with the shut lock (Index = 1 in my imagelist)

 

Re:Help needed with TreeView icons!


Lina,

I don't know why, but StateIndex = 0 doesn't work. So insert into ImageList1
some dummy image at index 0 and use indexes 1 and 2.

Hope this helps,
                        Zdenek

In article <01bd4534$73aee6a0$9a929a8e@default>,
  "Lina Scarpellini" <l...@info-internet.net> wrote:

Quote

> Hi everybody !
> I have a treeview which list the different forms completed for a patient.
> I'm trying to put an icon in front of the node's text to show if it is a
> locked or unlocked questionnaire (reflecting the state of a boolean field
> in the database)
> I have tried so many things but I'm at a loss to find the write code or
> property.
> I'm able to add a particular icon to a given item in the treeview but I
> can't figure out how come i can't assign the right icon depending of the
> field's value.

> Here is a piece of code (a kind of prototype). If I answer no , I get the
> open lock, which is correct. But if I answer Yes, I get nothing !

> Can someone help me please ? Moreover, you have to consider that I have to
> repeat this to different given items in my treeview (working with the item
> indexes...)
> Thanks in advance !!
> Lina

> procedure TForm1.Button1Click(Sender: TObject);
> var
>    i:integer;
> begin
> TreeView1.StateImages:= ImageList1;
> if MessageDlg('Est-ce que c''est verrouill ?',
>     mtConfirmation, [mbYes, mbNo], 0) = mrYes then
>     TreeView1.Items[3].StateIndex:= 0
> else
>    TreeView1.Items[3].StateIndex:= 1;

> end;

> It works only with the shut lock (Index = 1 in my imagelist)

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading

Other Threads