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 Backspace in KeyPress entfernt (https://www.delphipraxis.net/56358-backspace-keypress-entfernt.html)

Nalincah 4. Nov 2005 15:01


Backspace in KeyPress entfernt
 
Ich lass über KeyPress nur bestimmte Zeichen zu:

Delphi-Quellcode:
//------------------------------------------------------------------------------
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
  if not (Key in ['0'..'9','a'..'z','A'..'Z','+','-','/','\']) then Key := #0;
end;
Leider kann ich keine Backspace mehr drücken um Zeichen zu löschen? Wie kann ich da ne ausnahme machen?? Backspace liefert mir kein anständiges Char zurück

Nalincah 4. Nov 2005 15:15

Re: Backspace in KeyPress entfernt
 
Habs gefunden

Delphi-Quellcode:
//------------------------------------------------------------------------------
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
  if not (Key in ['0'..'9','a'..'z','A'..'Z','+','-','/','\',#0..#31]) then Key := #0;
end;

Sharky 5. Nov 2005 06:05

Re: Backspace in KeyPress entfernt
 
Hai General2004,

nur als Info ;-) BackSpace hat den ASCII-Code 8. Du musst also nicht alle Zeichen von 0-31 zulassen. Einfach ,#0..#31 durch #8 ersetzen.


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