Welcome to WindowsClient.net | Sign in | Join

Here are some frequently asked questions about Windows Forms and their answers.

Windows Forms FAQs

How do I format numbers, dates and currencies in a TextBox?

Each type has a ToString method that can be used to perform formatting. Also, you can use the String.Format method to format things as well. To format dates, use the ToString member of DateTime. You may want to use the InvariantInfo setting to get culture-independent strings.

float f = 444.4444f;
textBox1.Text = f.ToString( "c2" );

or

textBox1.Text = String.Format( "{0:c2}", f );

For standard and custom formatting codes, see Formatting Types in the .NET Framework Developer's Guide in the MSDN Library, including Standard Numeric Format Strings and Standard DateTime Format Strings.

George Shepherd, Syncfusion, and Stuart Celarier, Fern Creek



Page view counter