1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
| unit Unit8;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Data.Bind.EngExt, Vcl.Bind.DBEngExt,
System.Rtti, System.Bindings.Outputs, Vcl.Bind.Editors, Data.Bind.Components,
Vcl.StdCtrls;
type
TForm8 = class(TForm)
Edit1: TEdit;
Memo1: TMemo;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
Button1: TButton;
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure Button1Click(Sender: TObject);
procedure Edit2KeyPress(Sender: TObject; var Key: Char);
procedure FormCreate(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form8: TForm8;
implementation
{$R *.dfm}
procedure TForm8.Button1Click(Sender: TObject);
begin
Memo1.Lines.Clear;
end;
procedure TForm8.Edit1KeyPress(Sender: TObject; var Key: Char);
// avec passage vers Edit2
begin
if Key=#13 then
begin
Memo1.Lines.Add('Edit1 '+ Edit1.text);
SelectNext(Sender as TWinControl,True,True); // renvoi au prochain contrôle
end;
end;
procedure TForm8.Edit2KeyPress(Sender: TObject; var Key: Char);
// saisie en "rafale" on reste sur le même composant
begin
if Key=#13 then
begin
Key:=#0;
Memo1.Lines.Add('Edit2 '+ Edit2.text);
Edit2.Text:='';
end;
end;
procedure TForm8.FormCreate(Sender: TObject);
begin
Memo1.Lines.Clear;
Edit1.SetFocus; // par précaution
end;
end. |