DataGridTextBoxColumn.FormatInfo Eigenschaft

Definition

Ruft die kulturabhängigen Informationen ab, mit denen die Formatierung von Werten bestimmt wird, oder legt diese fest.

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

Eigenschaftswert

IFormatProvider

Ein Objekt, das die IFormatProvider-Schnittstelle implementiert, z. B. die CultureInfo-Klasse.

Attribute

Beispiele

Im folgenden Beispiel wird ein neues CultureInfo Objekt erstellt und der FormatInfo Eigenschaft eines DataGridTextBoxColumn Objekts zugewiesen. Im Beispiel wird auch die Eigenschaft auf "c" festgelegt, um anzugeben, dass die Format Spalte Werte als Währung anzeigen soll.

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

Hinweise

Wenn Sie die Format Eigenschaft auf eine der Formatierungszeichen festlegen, verwendet die DataGridTextBoxColumn von der FormatInfo Eigenschaft bereitgestellten Informationen weiter, um anzugeben, welche kulturspezifische Formatierung verwendet werden soll. Wenn die Format Eigenschaft z. B. auf das Formatzeichen "c" (für Währung) festgelegt ist, können Sie weiter angeben, dass das Symbol für die Lira verwendet werden soll. Erstellen Sie dazu ein neues CultureInfo Objekt mit der Gebietsschema-ID für Italien, und legen Sie die FormatInfo Eigenschaft auf das neue CultureInfo Objekt fest.

Weitere Informationen zum Formatieren von Zeichen finden Sie unter Formatierungstypen und benutzerdefinierte Datums- und Uhrzeitformatzeichenfolgen.

Gilt für

Siehe auch