The following example show you how to validate an Integer. If TEdit input change is valid value then ClearUndo else Undo The method I will use with OnChange event work like the following statement: Undo and ClearUndo procedure used by components belong to TCustomEdit class (such TEdit, TMaskedit, TMemo, TRichEdit.), we call Undo procedure to cancel all changes made to the TCustomEdit text since the last call to the ClearUndo procedure, and we call ClearUndo to commit changes to TCustomEdit text, after the excecuting of ClearUndo procedure, Undo procedure does nothing until the TCustomEdit text has.a new changes. My idea basing on Undo and ClearUndo procedures of TEdit Control. OnKeyPress event analyzes keyboard inputs, but doesn't work with Copy/Paste or Ctrl + V keyboard shortcut, for that i found that, OnChange event is better to catch any kinds of inputs. What problems aren't covered by OnKeyPress event? Procedure TForm1.Edit12KeyPress(Sender: TObject var Key: Char) begin if not (Key in ) then Key := #0 end Usually, programmer use OnKeyPress event to validate number input (Integer for example) like the following example TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. This Article will show you how to validate number with TEdit control,
0 Comments
Leave a Reply. |