Board index » delphi » Moving between DBedit fields with enter key

Moving between DBedit fields with enter key

Quote
>Igor Vedernjak wrote:

>> How can I move between DBEdit fields or call some procedure with Enter
>> key.

And Annie wrote:

>procedure TForm1.FormKeyPress(Sender:Tobject;var key:Char);
>begin
>  if key = #13 then
>     if not (activeControl is TDBGrid)
>       then begin
>              Key:=#0;
>              Perform(WM_NEXTDLGCTL,0,0);
>            end
>       else if Grid1.SelectedIndex < FieldCount-1
>              then Grid1.SelectedIndex:=Grid1.SelectedIndex+1
>              else Grid1.SelectedIndex:=0;
>end;

>Set the form's KeyPreview proprety to True

>Annie.

I use FormKeyDown but I can't develope :

procedure TAForm.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = VK_RETURN then begin
    { I want move between Data fields only by using ENTER key}
    if not (activeControl is TBitBtn) then begin
      Key := 0;
      if (activeControl = TheLastDBEdit) then
        TheFirstDBEdit.SetFocus
      else
        Perform(WM_NEXTDLGCTL, 0, 0);
    end
  end;
  { this block don't work - VK_TAB don't perform }
  if Key = VK_TAB then begin
    Key := 0;
    { my code }
    end;
  end;
end;

Eugene

 

Re:Moving between DBedit fields with enter key


Quote

> I use FormKeyDown but I can't develope :

> procedure TAForm.FormKeyDown(Sender: TObject; var Key: Word;
>   Shift: TShiftState);
> begin
>   if Key = VK_RETURN then begin
>     { I want move between Data fields only by using ENTER key}
>     if not (activeControl is TBitBtn) then begin
>       Key := 0;
>       if (activeControl = TheLastDBEdit) then
>         TheFirstDBEdit.SetFocus
>       else
>         Perform(WM_NEXTDLGCTL, 0, 0);
>     end
>   end;
>   { this block don't work - VK_TAB don't perform }
>   if Key = VK_TAB then begin
>     Key := 0;
>     { my code }
>     end;
>   end;
> end;

> Eugene

Well then set the TobStop to false

                                  Arnon

Other Threads