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 Key = '*' -> Edit1.Text = Akt. Datum (https://www.delphipraxis.net/27404-key-%3D-%2A-edit1-text-%3D-akt-datum.html)

Nalincah 9. Aug 2004 14:40


Key = '*' -> Edit1.Text = Akt. Datum
 
Ich hab ein Edit-Feld. Wenn man '*' drückt soll das aktuelle Datum reingeschrieben werden

Delphi-Quellcode:
procedure TForm1.EditBisDatumKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  case key of
    106 : begin
            key := 0;
            TEdit(Sender).Text := DateToStr(Date);
          end;
  end;
end;
Leider steht hier aber "*09.08.2004". Wie kann ich das "*" rauskriegen?

Sharky 9. Aug 2004 14:47

Re: Key = '*' -> Edit1.Text = Akt. Datum
 
Hai General,

versuche es mal so im OnKeyPress:
Delphi-Quellcode:
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
  if (Key = '*') then
   begin
     Key := #0;
     TEdit(Sender).Text := DateToStr(Date);
   end;
end;

beny_fritz 9. Aug 2004 14:47

Re: Key = '*' -> Edit1.Text = Akt. Datum
 
Hi,
Irgendwie bisch im Falschen Event und hasch den Falschen ASCII-Code.
So geht's:



Delphi-Quellcode:
procedure TForm1.EditBisDatumKeyPress(Sender: TObject; var Key: Char);
begin
  case key of
    #42 : begin
            key := #0;
            TEdit(Sender).Text := DateToStr(Date);
          end;
  end;
end;
Gruss Beny


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:07 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