I want to add "," to after every group of 3 digits. Eg : when I type 3000000 the textbox will display 3,000,000 but the value still is 3000000.
I tried to use maskedtexbox, there is a drawback that the maskedtexbox displayed a number like _,__,__ .
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Carriage Return (ASCII chr 13) is missing from tex
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
Try adding this code to
KeyUp
event handler of yourTextBox
Yes, it will change the value stored in a texbox, but whenever you need the actual number you can use the following line to get it from the text:
Of course do not forget to check that what the user inputs into the textbox is actually a valid integer number.
This may work fine for your scenario I hope.
Here, myTxt = your Textbox. Set Textchanged event as given below and create a property text as in the post.
Hope it helps.
You could hook up to OnKeyUp event like this:
Get Decimal Value Then set
Use String.Format
http://msdn.microsoft.com/en-us/library/system.string.format.aspx