Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI bax i cant solve my problem yet please help me i want when im typing in one column of grid the number separating automatic by ","
for exam when im typing 12365432 its IMMEDIATe convert to 123,654,32
thanks
Posted
Comments
Sandeep Mewara 7-Mar-13 10:29am    
It would be good to share what you were trying that you could not get it working. Update the question with it.
fatima...68 9-Mar-13 4:33am    
hi my friend i want to convert a number like 4561230 to 4,561,230 as when user typing. its mean in one column of data grid view when user type the forth number last three number automatically separate from right whit ","
is it clear?

1 solution

From what I understood, you wish to update on every user interaction (e.g. when user is editing some number in TextBox).

If that is the case, it should be very easy, just hook up to proper event (probably TextChanged or something like that, MSDN is the place to find out more detailed information) and make your changes accordingly to the Text property.

Make sure that you check if there is any difference between string that you prepared to set as new value of Text property and the string that is in Text property and only change Text property if they are different to avoid infinite loop. The preparation of newly formatted string should be easy, you should remove thousand and decimal separator from string, pars it and parsed value convert to string. Or something like that.

Hope I was of any help to you.

Happy coding. :)
 
Share this answer
 
Comments
fatima...68 9-Mar-13 4:35am    
hi my friend its easy for text box but i want it for data grid view there is no event for that
Richard MacCutchan 9-Mar-13 4:53am    
There are events for individual cells in a DataGridView that should help you.
fatima...68 9-Mar-13 6:24am    
please explain more about it
thanks'
Richard MacCutchan 9-Mar-13 6:28am    
You need read the documentation and find the events, properties and methods that will help to solve your problem.
Sharp Robin 9-Mar-13 10:15am    
Thanks Richard! And yes fatima...68, Richard is right just read DataGridView.CellEndEdit Event. As I mentioned in my solution MSDN is the place.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900