Ver Mensaje Individual
  #5  
Antiguo 18-09-2016
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 36
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 carlosCalle.

A ver, fijate si te sirve con estos cambios:
Código Delphi [-]
...
interface

procedure TForm1.FormCreate(Sender: TObject);
begin
  elEdit.TabOrder := 0;
  // desactivar cambio de foco con Tab en otros controles.
  // foo_Ctrl1.TabStop := False;
  // ...
  DBGrid1.Enabled := False;
end;

// no van a salir del edit con el mouse...
procedure TForm1.FormActivate(Sender: TObject);
var
  R : TRect;
begin
  R := elEdit.BoundsRect;
  MapWindowPoints(Handle, 0, R, 2);
  ClipCursor(@R);
end;

// OnDrawColumnCell 
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
  gr: TDBGrid;
begin
  gr := TDBGrid(Sender);
  if gdSelected in State then
  begin
    gr.Canvas.Brush.Color := clBlue;
    gr.Canvas.Font.Color  := clWhite;
    gr.DefaultDrawColumnCell(Rect, DataCol, Column, State);
  end;
end;

// controlar que tecla se presionó
procedure TForm1.elEditKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  case Key of
    VK_DOWN   : begin
                  DataSet.Next;
                  Key := 0;
                end;
    VK_UP     : begin
                  DataSet.Prior;
                  Key := 0;
                end;
    VK_RETURN : begin  // recibe datos
                 DataSet.FieldByName('Campo-para-el_Edit').Value := el_Edit.Text; //(o la conversión correspondiente)
                //DataSet.FieldByName...
                //...    
                  DataSet.Post;
                end;
     VK_ESCAPE : Close; // Salir
  end;
end;

// restaurar área del mouse
procedure TForm1.FormDestroy(Sender: TObject);
begin
  ClipCursor(nil);
end;
(recuerda que es un ejemplo y que seguramente tengas que adaptarlo)

Saludos
__________________
Daniel Didriksen

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