Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Ruft die kulturabhängigen Informationen ab, mit denen die Formatierung von Werten bestimmt wird, oder legt diese fest.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)
Syntax
'Declaration
Public Property FormatInfo As IFormatProvider
'Usage
Dim instance As DataGridTextBoxColumn
Dim value As IFormatProvider
value = instance.FormatInfo
instance.FormatInfo = value
public IFormatProvider FormatInfo { get; set; }
public:
property IFormatProvider^ FormatInfo {
IFormatProvider^ get ();
void set (IFormatProvider^ value);
}
/** @property */
public IFormatProvider get_FormatInfo ()
/** @property */
public void set_FormatInfo (IFormatProvider value)
public function get FormatInfo () : IFormatProvider
public function set FormatInfo (value : IFormatProvider)
Eigenschaftenwert
Ein Objekt, das die IFormatProvider-Schnittstelle implementiert, z. B. die CultureInfo-Klasse.
Hinweise
Wenn die Format-Eigenschaft auf eines der Formatzeichen festgelegt wird, verwendet die DataGridTextBoxColumn die durch die FormatInfo-Eigenschaft bereitgestellten Informationen, um die zu verwendenden kulturspezifischen Formatierungen näher anzugeben. Wenn die Format-Eigenschaft z. B. auf das Formatzeichen "c" (für Currency: Währung) festgelegt ist, können Sie zusätzlich angeben, dass das Symbol für Lira verwendet werden soll. Erstellen Sie zu diesem Zweck 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 Formatzeichenfolgen für Datum und Uhrzeit und Standardmäßige Zahlenformatzeichenfolgen.
Beispiel
Im folgenden Beispiel wird ein neues CultureInfo-Objekt erstellt und der FormatInfo-Eigenschaft eines DataGridTextBoxColumn-Objekts zugewiesen. Außerdem wird im Beispiel die Format-Eigenschaft auf "c" festgelegt, um anzugeben, dass Werte in der Spalte als Währung angezeigt werden sollen.
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
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";
}
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(0x410);
/* 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.get_TableStyles().
get_Item("Orders").get_GridColumnStyles().
get_Item("OrderAmount")));
myGridTextBoxColumn.set_FormatInfo(ItalyCultureInfo);
myGridTextBoxColumn.set_Format("c");
} //ChangeColumnCultureInfo
private function ChangeColumnCultureInfo(){
// Create a new CultureInfo object using the
// the locale ID for Italy.
var ItalyCultureInfo : System.Globalization.CultureInfo = new CultureInfo(0x0410);
// Cast a column that holds numeric values to the
// DataGridTextBoxColumn type, and set the FormatInfo
// property to the new CultureInfo object.
var myGridTextBoxColumn : DataGridTextBoxColumn =
DataGridTextBoxColumn(myDataGrid.TableStyles["Orders"].
GridColumnStyles["OrderAmount"]);
myGridTextBoxColumn.FormatInfo = ItalyCultureInfo;
myGridTextBoxColumn.Format = "c";
}
Plattformen
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
DataGridTextBoxColumn-Klasse
DataGridTextBoxColumn-Member
System.Windows.Forms-Namespace
CultureInfo
DataGridTextBoxColumn.Format-Eigenschaft