Hi,
I'm sure this has been covered often, but none of my searches seems to find it.
I have a routine to remove a row from a TStringGrid if the user selects it.
The problem is that the onSelection event seems to be trigered twice:
procedure TForm1.StringGrid1Selection(Sender: TObject; aCol, aRow: Integer);
var i:integer;
begin
if messageDlg('Remove
'+StringGrid1.Cells[aCol,aRow]+'?',mtInformation,[mbYes,mbNo],0)=mrYes
then
begin
for i:=arow to StringGrid1.RowCount-2 do
begin
StringGrid1.Cells[0,i]:=StringGrid1.Cells[0,i+1];
StringGrid1.Cells[1,i]:=StringGrid1.Cells[1,i+1];
end;
StringGrid1.RowCount:=StringGrid1.RowCount-1;
end;
end;The user will click the item to be removed, the dialog will appear asking for confirmation to delete the row, but on clicking yes, while the row is deleted as expected, the dialog pops up again, asking the user if the next line should be deleted.
