Delphi - Insertar registro en dbgrib pulsando enter

 
Vista:

Insertar registro en dbgrib pulsando enter

Publicado por PACO (3 intervenciones) el 05/03/2004 15:25:02
Necesito saber que codigo tengo que poner cuando pulso intro por el dbgrid llegando a la ultima columna me inserte un nuevo registro. Muchas gracias de antemano.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Insertar registro en dbgrib pulsando enter

Publicado por Delfino (1216 intervenciones) el 05/03/2004 21:39:32
en la pagina de Borland..

Description:
Code to make the key act as the tab key while inside a grid.

This code also includes the processing of the key for the entire
application - including fields, etc. The grid part is handled in the
ELSE portion of the code. The provided code does not mimic the behavior
of the key stepping down to the next record when it reaches the last
column in the grid - it moves back to the first column - .

procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
{ This is the event handler for the FORM's OnKeyPress event! }
{ You should also set the Form's KeyPreview property to True }
begin
if Key = #13 then { if it's an enter key }
if not (ActiveControl is TDBGrid) then begin { if not on a TDBGrid }
Key := #0; { eat enter key }
Perform(WM_NEXTDLGCTL, 0, 0); { move to next control }
end
else if (ActiveControl is TDBGrid) then { if it is a TDBGrid }
with TDBGrid(ActiveControl) do
if selectedindex < (fieldcount -1) then { increment the field }
selectedindex := selectedindex +1
else
selectedindex := 0;
end;
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Insertar registro en dbgrib pulsando enter

Publicado por Delfino (1216 intervenciones) el 05/03/2004 21:44:35
en la pagina de Borland..

Description:
Code to make the key act as the tab key while inside a grid.

This code also includes the processing of the key for the entire
application - including fields, etc. The grid part is handled in the
ELSE portion of the code. The provided code does not mimic the behavior
of the key stepping down to the next record when it reaches the last
column in the grid - it moves back to the first column - .

procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
{ This is the event handler for the FORM's OnKeyPress event! }
{ You should also set the Form's KeyPreview property to True }
begin
if Key = #13 then { if it's an enter key }
if not (ActiveControl is TDBGrid) then begin { if not on a TDBGrid }
Key := #0; { eat enter key }
Perform(WM_NEXTDLGCTL, 0, 0); { move to next control }
end
else if (ActiveControl is TDBGrid) then { if it is a TDBGrid }
with TDBGrid(ActiveControl) do
if selectedindex < (fieldcount -1) then { increment the field }
selectedindex := selectedindex +1
else
selectedindex := 0;
end;
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Insertar registro en dbgrib pulsando enter

Publicado por Delfino (1216 intervenciones) el 05/03/2004 22:29:44
en esta pagina hay varios trucos para mejorar el DBGrid
http://delphi.about.com/b/a/027886.htm?PM=ss15_delphi
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar