Switching imagelist at runtime
Posted: 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;
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;