Click here to Skip to main content
16,020,877 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,

I am wirting a code using VS2010 and C#,
I have a textbox that accept only numeric value and i want them to be group by 3.
exemple: 1 =>1
10000 => 10 000, etc.

Thanks for ur help
Posted
Comments
Sunil Kumar Pandab 23-Aug-12 9:16am    
exemple: 1 =>1
10000 => 10 000, etc. What does that mean ? Pls improve your qn so that we can help you.
marcelle ngounou 23-Aug-12 9:29am    
is just mean that if the user types 10000, we should have 10 000. if he types 1 we should have 1.
thanks

1 solution

 
Share this answer
 
Comments
marcelle ngounou 23-Aug-12 9:40am    
Hi, Vani
Thanks for your help, but it does not solve the problem. Because, the MaskedEditTexbox, limit the number of digit, thus i don't want it to be limited... and if your mask is "000 000", if you write "500 00_" is very different from "50 000" that should be seen.
Vani Kulkarni 23-Aug-12 9:42am    
None of the links I provided helped you?
marcelle ngounou 23-Aug-12 9:55am    
I havetry the links on stackoverflow.com, it doesn't work.
when i write "txtMtCategorie.Text.ToString("#,##0", new System.Globalization.CultureInfo("fr-FR"));"
i have this error "Error 1 No overload for method 'ToString' takes 2 arguments "
....
marcelle ngounou 23-Aug-12 10:26am    
hi Vani,

finally i have made it. Thanks, i was forced to do it this way:


private void txtMtCategorie_TextChanged(object sender, EventArgs e)
{
if (txtMtCategorie.Text != "")
{
int Mavaleur = int.Parse(txtMtCategorie.Text.ToString().Trim(), System.Globalization.NumberStyles.AllowThousands);

txtMtCategorie.Text = Mavaleur.ToString("#,##0", new System.Globalization.CultureInfo("fr-FR"));
}
}

It works! is that a good way to do it?
thanks

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