I used Listview.items.item[X].caption for changing the first column in a listbox,but now I have to change further at runtime.The only way I see is getting the item from listbox as TListItem ,editing it,add it and change position,but that doesn't suit it,because I have many items on the listview.
Is there a simpler way to accomplish this ,like the way I change the first item?
Thanks in advance.
try this
//Add a item
var
ListItem : TListItem;
begin
ListViewItem.Items.BeginUpdate;
try
ListItem := ListViewItem.Items.Add;
ListItem.Caption := 'First Column Value';
ListItem.SubItems.Add('Second Column Value');
ListItem.SubItems.Add('Third Column Value');
finally
ListViewItem.Items.EndUpdate;
end;
end;
//Edit a Item
var
ListItem : TListItem;
begin
ListViewItem.Items.BeginUpdate;
try
ListItem := Listview.items.item[X];
ListItem.Caption := 'New first Column Value';
ListItem.SubItems[0]:='New Second Column Value';
ListItem.SubItems[1]:='New Third Column Value';
finally
ListViewItem.Items.EndUpdate;
end;
end;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With