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.
Initialisiert eine neue Instanz der DataGridColumnStyle-Klasse mit dem angegebenen PropertyDescriptor.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)
Syntax
'Declaration
Public Sub New ( _
prop As PropertyDescriptor _
)
'Usage
Dim prop As PropertyDescriptor
Dim instance As New DataGridColumnStyle(prop)
public DataGridColumnStyle (
PropertyDescriptor prop
)
public:
DataGridColumnStyle (
PropertyDescriptor^ prop
)
public DataGridColumnStyle (
PropertyDescriptor prop
)
public function DataGridColumnStyle (
prop : PropertyDescriptor
)
Parameter
- prop
Ein PropertyDescriptor, der die Attribute für die Spalte bereitstellt.
Hinweise
Zum Erstellen eines neuen DataGridColumnStyle müssen Sie zunächst den CurrencyManager für die Datenquelle der Tabelle abrufen, der die Spalte hinzugefügt werden soll. Weitere Informationen über das Abrufen bestimmter CurrencyManager-Objekte für ein Formular finden Sie unter CurrencyManager und BindingManager.
Über den CurrencyManager können Sie dann den PropertyDescriptor für die DataColumn abrufen, der die Daten für die Spalte bereitstellt.
Wenn Sie eine Instanz eines DataGridColumnStyle erstellen, werden die folgenden Lese-/Schreibeigenschaften initialisiert.
Eigenschaft |
Anfangswert |
|---|---|
HorizontalAlignment.Left |
|
NULL (Nothing in Visual Basic) |
|
-1 |
|
false |
|
"(null)" |
|
false |
Beispiel
Im folgenden Codebeispiel wird eine neue DataGridTextBoxColumn erstellt (abgeleitet vom DataGridColumnStyle) und der GridColumnStylesCollection eines DataGridTableStyle hinzugefügt.
Private Sub CreateNewDataGridColumnStyle()
Dim myDataSet As New DataSet("myDataSet")
' Insert code to populate the DataSet.
' Get the CurrencyManager for the table you want to add a column to.
Dim myCurrencyManager As CurrencyManager = CType _
(Me.BindingContext(myDataSet.Tables("Suppliers")), CurrencyManager)
' Get the PropertyDescriptor for the DataColumn.
Dim pd As PropertyDescriptor = _
myCurrencyManager.GetItemProperties()("City")
' Construct the DataGridColumnStyle with the PropertyDescriptor.
Dim myColumn As New DataGridTextBoxColumn(pd)
myColumn.MappingName = "City"
dataGrid1.TableStyles(0).GridColumnStyles.Add(myColumn)
End Sub
private void CreateNewDataGridColumnStyle(){
DataSet myDataSet = new DataSet("myDataSet");
// Insert code to populate the DataSet.
// Get the CurrencyManager for the table you want to add a column to.
CurrencyManager myCurrencyManager =
(CurrencyManager)this.BindingContext[myDataSet, "Suppliers"];
// Get the PropertyDescriptor for the DataColumn.
PropertyDescriptor pd = myCurrencyManager.GetItemProperties()["City"];
// Construct the DataGridColumnStyle with the PropertyDescriptor.
DataGridColumnStyle myColumn = new DataGridTextBoxColumn(pd);
myColumn.MappingName = "City";
dataGrid1.TableStyles[0].GridColumnStyles.Add(myColumn);
}
void CreateNewDataGridColumnStyle()
{
DataSet^ myDataSet = gcnew DataSet( "myDataSet" );
// Insert code to populate the DataSet.
// Get the CurrencyManager for the table you want to add a column to.
CurrencyManager^ myCurrencyManager = dynamic_cast<CurrencyManager^>(this->BindingContext[myDataSet, "Suppliers"]);
// Get the PropertyDescriptor for the DataColumn.
PropertyDescriptor^ pd = myCurrencyManager->GetItemProperties()[ "City" ];
// Construct the DataGridColumnStyle with the PropertyDescriptor.
DataGridColumnStyle^ myColumn = gcnew DataGridTextBoxColumn( pd );
myColumn->MappingName = "City";
dataGrid1->TableStyles[ 0 ]->GridColumnStyles->Add( myColumn );
}
private void CreateNewDataGridColumnStyle()
{
DataSet myDataSet = new DataSet("myDataSet");
// Insert code to populate the DataSet.
// Get the CurrencyManager for the table you want to add a column to.
CurrencyManager myCurrencyManager =
(CurrencyManager)(this.get_BindingContext().
get_Item(myDataSet, "Suppliers"));
// Get the PropertyDescriptor for the DataColumn.
PropertyDescriptor pd = myCurrencyManager.GetItemProperties().
get_Item("City");
// Construct the DataGridColumnStyle with the PropertyDescriptor.
DataGridColumnStyle myColumn = new DataGridTextBoxColumn(pd);
myColumn.set_MappingName("City");
dataGrid1.get_TableStyles().get_Item(0).
get_GridColumnStyles().Add(myColumn);
} //CreateNewDataGridColumnStyle
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
DataGridColumnStyle-Klasse
DataGridColumnStyle-Member
System.Windows.Forms-Namespace
DataColumn