I have a TStringGrid with AutoAdvance:= aaDown. When the user is in the bottom row of a Column that is not the last column, What I want is for Tab, Return or Down-Key to go to the Top Row of the next Column. I have code that does this, but it only works if the user does not type anything in the bottom cell. If they do, the focus goes to the next control instead of advancing the way I described. The code does execute, but it seems to be ignored. Any ideas?
procedure TForm1.sgAvarKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
with Sender as TstringGrid do begin
if (Col < ColCount-1) and (Row = RowCount-1) then begin
if Key in [VK_Tab,VK_RETURN,VK_DOWN] then begin
Col:= Col+1;
Row:= FixedRows;
Key:= 0;
end;
end;
end;
end;