Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

DataGridTextBoxColumn.FormatInfo Property

Gets or sets the culture specific information used to determine how values are formatted.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public IFormatProvider FormatInfo { get; set; }

Property Value

Type: System.IFormatProvider
An object that implements the IFormatProvider interface, such as the CultureInfo class.

When setting the Format property to one of the formatting characters, the DataGridTextBoxColumn uses the information provided by the FormatInfo property to further specify what cultural-specific formatting to use. For example, when the Format property is set to the format character "c" (for currency), you can further specify that the symbol for the lira be used. To do this, create a new CultureInfo object with the locale ID for Italy, and set the FormatInfo property to the new CultureInfo object.

For more information about formatting characters, see Formatting Types in the .NET Framework and Custom Date and Time Format Strings.

The following example creates a new CultureInfo object and assigns it to the FormatInfo property of a DataGridTextBoxColumn object. The example also sets the Format property to "c" to specify that the column should display values as currency.

private void ChangeColumnCultureInfo(){
   /* Create a new CultureInfo object using the 
   the locale ID for Italy. */
   System.Globalization.CultureInfo ItalyCultureInfo= 
   new CultureInfo(0x0410);

   /* Cast a column that holds numeric values to the   
   DataGridTextBoxColumn type, and set the FormatInfo
   property to the new CultureInfo object. */
   DataGridTextBoxColumn myGridTextBoxColumn = 
   (DataGridTextBoxColumn) myDataGrid.TableStyles["Orders"].
   myGridTextBoxColumn.FormatInfo = ItalyCultureInfo;
   myGridTextBoxColumn.Format = "c";

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
© 2015 Microsoft