Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Bei Enter ins nächste EDIT-Feld (https://www.delphipraxis.net/25101-bei-enter-ins-naechste-edit-feld.html)

burn 1. Jul 2004 08:18


Bei Enter ins nächste EDIT-Feld
 
Hallo allerseits,

habe eine Form mit mehreren Edits, Buttons, etc ...
Die Tabulator-Reihenfolge ist gemischt ...

Ich möchte folgendes erreichen:

Bei Enter in einem Edit-Feld soll auf das nächste Edit-Feld
gesprungen werden (nicht auf einen Button o.ä.)
Ist man im letzten Edit soll wieder aufs erste gegangen werden.


Jedoch möchte ich weiterhin die Möglichkeit haben,
wenn ich TAB drücke das der Focous dann aufs nächste Control( z.B. Button) geht.

Irgendwelche Vorschläge ???


Grüsse Steve

bernd2000 1. Jul 2004 08:27

Re: Bei Enter ins nächste EDIT-Feld
 
Hallo burn

Code:
procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
   if Key = #13 then Self.Perform(WM_NEXTDLGCTL, 0, 0);
end;
KeyPreview von Form1 auf true setzen nicht vergessen!!!

Gruß Bernd

Stevie 1. Jul 2004 08:27

Re: Bei Enter ins nächste EDIT-Feld
 
Delphi-Quellcode:
procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var
  NextControl: TWinControl;
begin
  if Key = VK_RETURN then
  begin
    NextControl := Sender as TWinControl;
    repeat
      NextControl := FindNextControl(NextControl, True, True, True);
    until NextControl.InheritsFrom(TEdit);
    NextControl.SetFocus;
  end;
end;

ibp 1. Jul 2004 08:29

Re: Bei Enter ins nächste EDIT-Feld
 
... hallo ...
wie wäre es mit dem onkey.. ereignis ...

burn 1. Jul 2004 08:39

Re: Bei Enter ins nächste EDIT-Feld
 
Thx to Stevie -> funzt bestens, genau das hab ich gesucht!!!

@bernd2000
-> die Möglichkeit hatte ich auch zuerst aber
ich bin immer nur im nächsten Control gelandet

Vielen Dank für die Mithilfe

Steve


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:05 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz