3
Answers

C# how to put comma for a dicimal in textbox?????

Sai Yang

Sai Yang

6y
3.5k
1
Dear
 
I have a text box which I want to contain only numbers and put comma for decimal (not dot).
 
I just use this code on Event Keypress:
 
if (char.IsNumber(e.KeyChar))
{
}
else
{
e.Handled = e.KeyChar != (char)Keys.Back;
}
 
This code allows only numbers. It does not match my needed.
 
How can I do that to allow only number and comma for decimal?
 
I would appreciate thanks for those solution.
Thank so much.
Answers (3)