|
Hi there,
How can I do a currency formatting for a text box in C#?
My requirement is - Text box should accept numbers only upto 2 decimal places and after focus is changed format should change like $3,454,54.89.
Thanks
|
|
|
|
|
Are you using databinding to get the value in there, or putting in the value manually? With databinding, it'd be using the FormatString[^] property of the binding;
textBox1.DataBindings.Add(new Binding(
"Text",
Properties.Settings.Default,
"ConnectionString",
true));
textBox1.Databinding[0].FormatString = "C";
Alternatively, you could keep the value in a private variable, set it when the user is done editing, and update with a formatted version when the focus is lost. A description of the markup can be found here[^].
If the subject is "new", MSDN has an introduction here[^].
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
modified 24-Oct-12 17:05pm.
|
|
|
|