I have an AdvStringGrid that I am loading with email information, 2 columns: display name and actual email address. After loading, I iterate the grid and add a check box to the first column.
I am now trying to iterate again and check any rows where the email address is in an AdvMemo component, showing that it has been previously selected. The memo content is saved on program exit and reloaded on program show. Save / reload works ok. There is never a match on the items though, or the check is not being applied as I expected in this code:
var Str : String;
...
for i := 1 to emailGrid.RowCount - 1 do
begin
Str := trim(emailGrid.Cells[1,i]); // the email address column
if AdvMemo1.Lines.Count > 0 then
for j := 1 to AdvMemo1.Lines.Count do
begin
if Str = trim(AdvMemo1.Lines.Text[j]) then
emailGrid.SetCheckBoxState(0,i,true); // the display name column
end;
end;
Am I calling the wrong function to make the checkbox checked? Is it OK to use this function in the Form1.OnShow event?