Delphi – update TListView item

delphilistview

I want to update values in a TListView. I tryed this

...
lvProcess : TListView;
liEdit : TlistItem;
...
   liEdit:=lvProcess.Items.Item[1];
   liEdit.Caption:='11';
   liEdit.SubItems.ValueFromIndex[0]:='22';
   liEdit.SubItems.ValueFromIndex[1]:='33';
...

this should do what I want, but after this, the values of the subitems are this ones '=22' and '=33'
I don't want the equal character to be added.

Can anyone help me? I don't know if this is the right way to edit/update a listitem

thanks

Best Solution

You could try the following :

with LvProcess.Items[1] do
begin
  Caption := '11';
  SubItems.Strings[0] := '22';
  SubItems.Strings[1] := '33';
end;

And if you're updating many items at once it is better to surround the update in a way like this:

try
  lvProcess.Items.BeginUpdate;

  //Do your updates
finally
  lvProcess.Items.EndUpdate;
end;
Related Question