How can I change the TEdit's default error message when I use it in NumbersOnly mode. I mean this error:
Unacceptable character You can only type a number here
Is it possible to change this message ?
I don't know a direct way to change the value of that message (which is handled by Windows) but you can show your own message and then avoid to show the original windows hint ballon, using the Abort
procedure in the OnKeyPress
Event.
Check this sample
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if not (CharInSet(Key,['0'..'9',#8,#9])) then
begin
ShowHintMessage('Only numbers please');//you must write this function
Abort;//this will prevent which the original windows hint was shown
end;
end;
You must we aware which this code will be prevent the execution of the clipboard operations over the control.
Update
I Update the code to allow the Tab(#9) and Back space(#8) chars.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With