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)

[BrowsableAttribute(false)]
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"].
   GridColumnStyles["OrderAmount"];
   myGridTextBoxColumn.FormatInfo = ItalyCultureInfo;
   myGridTextBoxColumn.Format = "c";
}

.NET Framework

Supported in: 4.5.3, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft