I googled the web for hours but couldn't find my answer. I need when a user types or copies any number in TextBox then the number should follow the bellow rules:
Update For example,
123 => 123
1234.00 => 1,234
123456.05 => 123,456.05
123456.50 => 123,456.5
How can I do this?
The easiest way would be to try to parse value as a number.
decimal value;
if(decimal.TryParse(textBox.Text, out value)
{
//value is ok
textBox.Text = string.Format("{0}", value);//If you want some fancier formatting
}
else
{
//Value is not valid
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.