Jump to content

Replace "." to "," in UniEdit


brunotoira
 Share

Recommended Posts

Hello,

I need to setup UniEdit to accept only chars:

 

0..9 and "," Backspace and "-" to negative numbers.

 

i create this function, but if i press "." (point) doesnt change to "," (comma)

 

 

Anyway to do this?

procedure TDataModule1.AllowedChars(Sender: TObject; var Key: Char);
begin
  If sender is TUniEdit then
  Begin
    if charinset(Key,[backspace, '0'..'9'])=True then exit;
    if ((Key = '.')OR(Key = ',')) and (Pos(',', TUniEdit(sender).Text) = 0) {and (TUniEdit(sender).s <> 0)} then
    BEGIN
      KEY:=',';
      exit;
    END;
    if (Key = '-') {and (TUniEdit(sender).SelStart = 0)}
     and (pos('-',TUniEdit(sender).text)=0) then  exit;
    Key := #0;
  end;
end;

 

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.

 Share

×
×
  • Create New...