Düzenle

Aracılığıyla paylaş


DataGridTextBoxColumn.FormatInfo Property

Definition

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

public:
 property IFormatProvider ^ FormatInfo { IFormatProvider ^ get(); void set(IFormatProvider ^ value); };
[System.ComponentModel.Browsable(false)]
public IFormatProvider FormatInfo { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.FormatInfo : IFormatProvider with get, set
Public Property FormatInfo As IFormatProvider

Property Value

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

Attributes

Examples

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 = gcnew 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 =
         dynamic_cast<DataGridTextBoxColumn^>(myDataGrid->TableStyles[ "Orders" ]->
         GridColumnStyles[ "OrderAmount" ]);
      myGridTextBoxColumn->FormatInfo = ItalyCultureInfo;
      myGridTextBoxColumn->Format = "c";
   }
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";
}
Public Class Form1:Inherits Form
private myDataGrid as DataGrid    
    Public Shared Sub Main()
        Dim t As New Form1()
        ' Write a purchase order.
    End Sub
Private Sub ChangeColumnCultureInfo()
   ' Create a new CultureInfo object using the 
   ' the locale ID for Italy. 
   Dim ItalyCultureInfo As CultureInfo = New _
   CultureInfo(&H0410)
   ' Cast a column that holds numeric values to the   
   ' DataGridTextBoxColumn type, and set the FormatInfo
   ' property to the new CultureInfo object. 
   Dim myGridTextBoxColumn As DataGridTextBoxColumn = _
   CType( myDataGrid.TableStyles("Orders"). _
   GridColumnStyles("OrderAmount"), DataGridTextBoxColumn)
   myGridTextBoxColumn.FormatInfo = ItalyCultureInfo
   myGridTextBoxColumn.Format = "c"
End Sub

Remarks

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 and Custom Date and Time Format Strings.

Applies to

See also