Question

I have a Valuelisteditor that looks like this

Key   |  Name  |
---------------|
Car   |  Audi  |
Nick  |  Yummi |
Age   |  70    |

and I want to modify the key "Nick" in Row 2 and keep the Name "Yummi".
I do not want to rewrite the whole row.
I just want to change "Nick" in "Nickname".

How can I do this in one strike?

Was it helpful?

Solution

Find the row you want to change, and then update the appropriate Cell:

var
  iRow: Integer;
begin
  // Find the row containing 'Nick' as the key
  ValueListEditor1.FindRow('Nick', iRow);
  // If it was found, update the key value (column 0 of the row)
  if iRow > -1 then
    ValueListEditor1.Cells[0, iRow] := 'NewNick';
end;

Note that TValueListEditor.Cells are 0 based, where the columns are Keys (column 0) and Values (column 1).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top