Ver Mensaje Individual
  #4  
Antiguo 28-09-2015
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 38
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola shoulder.

A ver si esto es lo que estas buscando...
Código Delphi [-]
...
type
  TForm1 = class(TForm)
  ...
  private
    procedure DataSetAfterPost(DataSet: TDataSet);
  public
  end;

...

implementation

procedure TForm1.FormCreate(Sender: TObject);
begin
  DBGrid1.DataSource.DataSet.AfterPost := DataSetAfterPost;
end;

type
  TDBGridEx = class(TDBGrid);

procedure GotoCurrentRow(Grid: TDBGrid);
var
  ti: array [0..1] of TInput;
  p : TPoint;
  R : TRect;
  cr: Integer;
begin
  cr := TDBGridEx(Grid).Row;
  R  := TDBGridEx(Grid).CellRect(0, cr);
  p  := Form1.ClientToScreen(Point(Grid.Left+IndicatorWidth+10, R.Top+10));
  Mouse.CursorPos := p;
  ZeroMemory(@ti, SizeOf(ti));
  ti[0].mi.dwFlags := MOUSEEVENTF_LEFTDOWN;
  ti[0].Itype      := INPUT_MOUSE;
  ti[1].mi.dwFlags := MOUSEEVENTF_LEFTUP;
  ti[1].Itype      := INPUT_MOUSE;
  SendInput(2, ti[0], SizeOf(TInput));
end;

// Despues de guardar, ir a la fila
procedure TForm1.DataSetAfterPost(DataSet: TDataSet);
begin
  GotoCurrentRow(DBGrid1);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  DBGrid1.DataSource.DataSet.AfterPost := nil;
end;

Saludos
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita