How to assign an image to a Listview Item?

Asked

Viewed 1,591 times

1

How do I assign an Image to a Listview Item? I want to place an image according to the status of the process. Initially only get by making statusbar with external components, but I can not use external. Then I will use an image according to the status will change the color, because rectangle could not also. This is what I am trying:

var
  listStatusExame           : TList<TImage>;
  txtStatusExame            : TListItemImage;
begin
  listStatusExame           := TList<TImage>.Create;

  listview1.BeginUpdate;

  for I := 0 to (listview1.Items.Count - 1) do
  begin
    txtStatusExame := TListItemImage(lvwAtendimentos.Items[i].Objects.FindDrawable
      ('status_img'));
    listStatusExame.add(Image1);
    txtStatusExame.ImageSource.ImageList := ImageList1;
  end;
end.

If someone knows how to add a rectangle to a Listview Item, it would be even better, please.

1 answer

1

If I understood your question correctly, the simplest way would be to link an Imagelist to Listview and then indicate in the Listview item the index of the image that will be used.

It is possible to change the image at runtime.

As I’m a little short of time to create an example application I ended up taking some prints of doing an edition in Paint even to show what I’m talking about.

I hope it helps you.

inserir a descrição da imagem aqui

  • If it’s not very clear, let me know, I can try to improve the explanation.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.