Lenguaje de programación Borland Delphi
Símplemente pon este código en el evento OnKeyDown de tu Formulario y pon la propiedad KeyPreview del mismo a TRUE.
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key in [VK_UP,VK_DOWN] then
begin
if Key = VK_UP then Perform(WM_NEXTDLGCTL, 1, 0)
else Perform(WM_NEXTDLGCTL, 0, 0);
Key:=0;
end;
end;
Si por ejemplo queremos que no funcione con los DBGrids, o algún otro control, bastaría con añadir algo al primer IF.
Por ejemplo, para que no funcione en los DBGrids:
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (Key in [VK_UP,VK_DOWN]) and
Not (ActiveControl is TDBGrid) then
begin
if Key = VK_UP then Perform(WM_NEXTDLGCTL, 1, 0)
else Perform(WM_NEXTDLGCTL, 0, 0);
Key:=0;
end;
end;
Publicado el: 2003-09-29