Switching imagelist at runtime

TeeTree VCL for Borland Delphi and C++ Builder.
Post Reply
Lenfors
Newbie
Newbie
Posts: 49
Joined: Thu Sep 20, 2007 12:00 am

Switching imagelist at runtime

Post by Lenfors » Tue May 25, 2010 10:23 am

Hello!

I have two ImageLists containing the same icons in 16*16 and 32*32. Now I want to change all my icons in my TTree.

I tried the code below, but there is no change to the icons! How Do I update them during runtime?

Regards, Mikael


Procedure TForm4.B_BigIconClick(Sender: TObject);
Begin
Tree.Images := TreeImageListBig; '' <- Nothing happenes here so try to reload all icons
ReloadIcons;
End;

Procedure TForm4.B_SmallIconClick(Sender: TObject);
Begin
Tree.Images := TreeImageListSmall;
ReloadIcons;
End;

Procedure TForm4.ReloadIcons;
Var I: Integer;
Begin
For I := 0 To Tree.Items.Count - 1 Do
Begin
Tree.Items.ImageListIndex := -1; '' <- Tried to reset the icon here to be able to reload it below, but it does not change
Tree.Items.ImageListIndex := Tree.Items.ImageListIndex;
Tree.Items.Repaint;
End;
End;

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Switching imagelist at runtime

Post by Yeray » Wed May 26, 2010 9:07 am

Hi Mikael,

I think that you only need a Tree1.Draw to refresh the icons.
See the attached project.
Attachments
reload_icons.zip
(12 KiB) Downloaded 1042 times
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply