Good morning. I'm having an issue which I can't seem to figure out.
I am using a TAdvStringGrid and attempting to add a row and select the added cell when the VK_DOWN key is pressed. I use the OnKeyDown event to capture the VK_DOWN key and when the current row is equal to the last row, I add a new row and want to auto select the new row. The row gets added just fine, but the previous row stays selected and I have to press the down key again to get to the new row. Spending way too much time on this and have tried various different methods but it keeps reverting to the previous row. Any help would greatly be appreciated. Code example below...
procedure TfrmMain.DataKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
if (Sender is TAdvStringGrid) then begin
grd := (Sender as TAdvStringGrid);
if Key = VK_DOWN then begin
if grd.Row = imaxRow then begin
// adding a new row iRowNo := StrToInt(Grd.Cells[0,Grd.Row]) + 1; Grd.RowCount := Grd.RowCount + 1; i := Grd.RowCount - 1; // adding count to fixed col Grd.Cells[0,i] := iRowNo.ToString; // This should select the new row Grd.Row := i; Grd.Col := 1; end; end;