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 DataGridTextBoxColumn-Klasse.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)
Syntax
'Declaration
Public Sub New
'Usage
Dim instance As New DataGridTextBoxColumn
public DataGridTextBoxColumn ()
public:
DataGridTextBoxColumn ()
public DataGridTextBoxColumn ()
public function DataGridTextBoxColumn ()
Beispiel
Im folgenden Beispiel wird eine DataGridTextBoxColumn erstellt und der GridColumnStylesCollection hinzugefügt.
Private Sub AddColumn()
Dim myTable As New DataTable()
' Add a new DataColumn to the DataTable.
Dim myColumn As New DataColumn("myTextBoxColumn")
myColumn.DataType = System.Type.GetType("System.String")
myColumn.DefaultValue = "default string"
myTable.Columns.Add(myColumn)
' Get the CurrencyManager for the DataTable.
Dim cm As CurrencyManager = CType(Me.BindingContext(myTable), CurrencyManager)
' Use the CurrencyManager to get the PropertyDescriptor for the new column.
Dim pd As PropertyDescriptor = cm.GetItemProperties()("myTextBoxColumn")
Dim myColumnTextColumn As DataGridTextBoxColumn
' Create the DataGridTextBoxColumn with the PropertyDescriptor.
myColumnTextColumn = New DataGridTextBoxColumn(pd)
' Add the new DataGridColumn to the GridColumnsCollection.
dataGrid1.DataSource = myTable
dataGrid1.TableStyles.Add(New DataGridTableStyle())
dataGrid1.TableStyles(0).GridColumnStyles.Add(myColumnTextColumn)
End Sub 'AddColumn
private void AddColumn()
{
DataTable myTable= new DataTable();
// Add a new DataColumn to the DataTable.
DataColumn myColumn = new DataColumn("myTextBoxColumn");
myColumn.DataType = System.Type.GetType("System.String");
myColumn.DefaultValue="default string";
myTable.Columns.Add(myColumn);
// Get the CurrencyManager for the DataTable.
CurrencyManager cm = (CurrencyManager)this.BindingContext[myTable];
// Use the CurrencyManager to get the PropertyDescriptor for the new column.
PropertyDescriptor pd = cm.GetItemProperties()["myTextBoxColumn"];
DataGridTextBoxColumn myColumnTextColumn;
// Create the DataGridTextBoxColumn with the PropertyDescriptor.
myColumnTextColumn = new DataGridTextBoxColumn(pd);
// Add the new DataGridColumn to the GridColumnsCollection.
dataGrid1.DataSource= myTable;
dataGrid1.TableStyles.Add(new DataGridTableStyle());
dataGrid1.TableStyles[0].GridColumnStyles.Add(myColumnTextColumn);
}
private:
void AddColumn()
{
DataTable^ myTable = gcnew DataTable;
// Add a new DataColumn to the DataTable.
DataColumn^ myColumn = gcnew DataColumn( "myTextBoxColumn" );
myColumn->DataType = System::Type::GetType( "System::String" );
myColumn->DefaultValue = "default string";
myTable->Columns->Add( myColumn );
// Get the CurrencyManager for the DataTable.
CurrencyManager^ cm = dynamic_cast<CurrencyManager^>(this->BindingContext[ myTable ]);
// Use the CurrencyManager to get the PropertyDescriptor for the new column.
System::ComponentModel::PropertyDescriptor^ pd = cm->GetItemProperties()[ "myTextBoxColumn" ];
DataGridTextBoxColumn^ myColumnTextColumn;
// Create the DataGridTextBoxColumn with the PropertyDescriptor.
myColumnTextColumn = gcnew DataGridTextBoxColumn( pd );
// Add the new DataGridColumn to the GridColumnsCollection.
dataGrid1->DataSource = myTable;
dataGrid1->TableStyles->Add( gcnew DataGridTableStyle );
dataGrid1->TableStyles[ 0 ]->GridColumnStyles->Add( myColumnTextColumn );
}
private void AddColumn()
{
DataTable myTable = new DataTable();
// Add a new DataColumn to the DataTable.
DataColumn myColumn = new DataColumn("myTextBoxColumn");
myColumn.set_DataType(System.Type.GetType("System.String"));
myColumn.set_DefaultValue("default string");
myTable.get_Columns().Add(myColumn);
// Get the CurrencyManager for the DataTable.
CurrencyManager cm = (CurrencyManager)(this.get_BindingContext().
get_Item(myTable));
// Use the CurrencyManager to get the PropertyDescriptor
// for the new column.
PropertyDescriptor pd = cm.GetItemProperties().
get_Item("myTextBoxColumn");
DataGridTextBoxColumn myColumnTextColumn;
// Create the DataGridTextBoxColumn with the PropertyDescriptor.
myColumnTextColumn = new DataGridTextBoxColumn(pd);
// Add the new DataGridColumn to the GridColumnsCollection.
dataGrid1.set_DataSource(myTable);
dataGrid1.get_TableStyles().Add(new DataGridTableStyle());
dataGrid1.get_TableStyles().get_Item(0).
get_GridColumnStyles().Add(myColumnTextColumn);
} //AddColumn
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
.NET Compact Framework
Unterstützt in: 2.0, 1.0
Siehe auch
Referenz
DataGridTextBoxColumn-Klasse
DataGridTextBoxColumn-Member
System.Windows.Forms-Namespace
DataColumn
DataGridColumnStyle-Klasse
DataGrid-Klasse