DataGridTextBoxColumn.Format Eigenschaft

Definition

Ruft das bzw. die Zeichen ab, die angeben, wie Text formatiert wird, oder legt diese fest.

public:
 property System::String ^ Format { System::String ^ get(); void set(System::String ^ value); };
public string Format { get; set; }
member this.Format : string with get, set
Public Property Format As String

Eigenschaftswert

Das bzw. die Zeichen, die angegeben, wie Text formatiert wird.

Beispiele

Im folgenden Beispiel wird ein neues CultureInfo -Objekt erstellt und der FormatInfo -Eigenschaft eines DataGridTextBoxColumn -Objekts zugewiesen. Im Beispiel wird die Format -Eigenschaft auch auf "c" festgelegt, um anzugeben, dass die 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

Die Format -Eigenschaft gibt an, wie Werte in der Spalte angezeigt werden. Legen Sie beispielsweise die -Eigenschaft auf "c" fest, um anzugeben, dass die Werte als lokale Währung formatiert werden. Der CultureInfo für den Computer wird verwendet, um das tatsächliche Währungsformat zu bestimmen. Die Werte werden automatisch in den nativen Typ formatiert, wenn Daten geändert werden.

Weitere Informationen zum Formatieren von Zeichen finden Sie unter Formatierungstypen und benutzerdefinierte Formatzeichenfolgen für Datum und Uhrzeit.

Das format, das Sie anwenden, sollte für den Datentyp geeignet sein. Wenn die Daten z. B. numerisch sind, verwenden Sie eine der numerischen Formatzeichenfolgen.

Sie können die für eine ändern, DataGridTextBoxColumn indem Sie die FormatInfo -Eigenschaft auf eine neue CultureInfo Instanz festlegen, die CultureInfo mit einer entsprechenden Kultur-ID erstellt wurde.

Um die CultureInfo für die Anwendung festzulegen, legen Sie die CurrentCulture -Eigenschaft des -Objekts auf eine neue CultureInfo Instanz fest, die Application mit einer entsprechenden Kultur-ID erstellt wurde.

Gilt für:

Weitere Informationen