Jump to content

Replace "." to "," in UniEdit


brunotoira

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...