Sai Yang

Sai Yang

  • NA
  • 136
  • 27.2k

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

Apr 4 2018 6:43 AM
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)