Herwan Alhadi Posted October 9, 2022 Share Posted October 9, 2022 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 Quote Link to comment Share on other sites More sharing options...
AleksZ Posted October 10, 2022 Share Posted October 10, 2022 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; 1 Quote Link to comment Share on other sites More sharing options...
Roberto Nicchi Posted October 10, 2022 Share Posted October 10, 2022 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 ... 1 Quote Link to comment Share on other sites More sharing options...
albertovesx Posted October 11, 2022 Share Posted October 11, 2022 I think that is better to use a client side approach like this 1 Quote Link to comment Share on other sites More sharing options...
Herwan Alhadi Posted October 16, 2022 Author Share Posted October 16, 2022 Thaks for all.. 😊 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.