Jump to content

Keypress in TUniEdit numeric only


Herwan Alhadi

Recommended Posts

Hi!

procedure TMainForm.UniEdit2Change(Sender: TObject);

function MyCif(s: string): Boolean;
  begin
    if (s = '0') or (s = '1') or (s = '2') or (s = '3') or (s = '4') or  (s = '5') or (s = '6') or (s = '7') or (s = '8') or (s = '9') then
      Result := True
    else
      Result := False;
  end;

begin

if not MyCif(Copy(UniEdit2.Text, Length(UniEdit2.Text), 1)) then
        UniEdit2.Text := Copy(UniEdit2.Text, 1, Length(UniEdit2.Text) - 1);

end;

  • Like 1
Link to comment
Share on other sites

On 10/9/2022 at 6:08 PM, Herwan Alhadi said:

To all members of the forum

 I am trying to use the keypress event to disallow some keys in a TUniEdit

procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
if not (key in[‘0’..’9′,#8]) then
key:=#0;
end;

still not work, how can do it

thaks

you could use the inputmask property to limit the valid input characters ...

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...