type TGridCracker = class(TStringGrid);
{...}
implementation
{...}
procedure SetCaretPosition(Grid: TStringGrid; col, row, x_pos: Integer); begin Grid.Col := Col; Grid.Row := Row; with TGridCracker(Grid) do InplaceEditor.SelStart := x_pos; end;
function GetCaretPosition(Grid: TStringGrid): Integer; begin with TGridCracker(Grid) do Result := InplaceEditor.SelStart; end;
//Пример
procedure TForm1.Button1Click(Sender: TObject); begin StringGrid1.SetFocus; SetCaretPosition(StringGrid1, 1, 3, 5); end;
|