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 einer DataGridTextBoxColumn mit einem 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 DataGridTextBoxColumn(prop)
public DataGridTextBoxColumn (
PropertyDescriptor prop
)
public:
DataGridTextBoxColumn (
PropertyDescriptor^ prop
)
public DataGridTextBoxColumn (
PropertyDescriptor prop
)
public function DataGridTextBoxColumn (
prop : PropertyDescriptor
)
Parameter
- prop
Der PropertyDescriptor für die Spalte, die der DataGridTextBoxColumn zugeordnet wird.
Hinweise
Der DataGridColumnStyle verwendet einen PropertyDescriptor, um den Typ der Daten zu bestimmen, die in der Spalte angezeigt werden. Verwenden Sie die GetItemProperties-Methode der BindingManagerBase-Klasse, um eine PropertyDescriptorCollection zurückzugeben.
Beispiel
Im folgenden Beispiel wird eine DataGridTextBoxColumn erstellt und der GridColumnStylesCollection hinzugefügt.
Private Sub AddColumn(myTable As DataTable)
' Add a new DataColumn to the DataTable.
Dim myColumn As New DataColumn("myTextBoxColumn")
myColumn.DataType = GetType(String)
myColumn.DefaultValue = "default string"
myTable.Columns.Add(myColumn)
' Get the ListManager for the DataTable.
Dim cm As CurrencyManager = CType(Me.BindingContext(myTable), CurrencyManager)
' Use the ListManager to get the PropertyDescriptor for the new column.
Dim pd As PropertyDescriptor = cm.GetItemProperties()("myTextBoxColumn")
' Create a new DataTimeFormat object.
Dim fmt As New DateTimeFormatInfo()
' Insert code to set format.
Dim myColumnTextColumn As DataGridTextBoxColumn
' Create the DataGridTextBoxColumn with the PropertyDescriptor and Format.
myColumnTextColumn = New DataGridTextBoxColumn(pd, fmt.SortableDateTimePattern)
' Add the new DataGridColumnStyle to the GridColumnsCollection.
dataGrid1.TableStyles(0).GridColumnStyles.Add(myColumnTextColumn)
End Sub 'AddColumn
private void AddColumn(DataTable myTable){
// Add a new DataColumn to the DataTable.
DataColumn myColumn = new DataColumn("myTextBoxColumn");
myColumn.DataType = typeof(String);
myColumn.DefaultValue="default string";
myTable.Columns.Add(myColumn);
// Get the ListManager for the DataTable.
CurrencyManager cm = (CurrencyManager)this.BindingContext[myTable];
// Use the ListManager to get the PropertyDescriptor for the new column.
PropertyDescriptor pd = cm.GetItemProperties()["myTextBoxColumn"];
// Create a new DataTimeFormat object.
DateTimeFormatInfo fmt = new DateTimeFormatInfo();
// Insert code to set format.
DataGridTextBoxColumn myColumnTextColumn;
// Create the DataGridTextBoxColumn with the PropertyDescriptor and Format.
myColumnTextColumn = new DataGridTextBoxColumn(pd, fmt.SortableDateTimePattern);
// Add the new DataGridColumnStyle to the GridColumnsCollection.
dataGrid1.TableStyles[0].GridColumnStyles.Add(myColumnTextColumn);
}
private:
void AddColumn( DataTable^ myTable )
{
// Add a new DataColumn to the DataTable.
DataColumn^ myColumn = gcnew DataColumn( "myTextBoxColumn" );
myColumn->DataType = String::typeid;
myColumn->DefaultValue = "default string";
myTable->Columns->Add( myColumn );
// Get the ListManager for the DataTable.
CurrencyManager^ cm = dynamic_cast<CurrencyManager^>(this->BindingContext[ myTable ]);
// Use the ListManager to get the PropertyDescriptor for the new column.
PropertyDescriptor^ pd = cm->GetItemProperties()[ "myTextBoxColumn" ];
// Create a new DataTimeFormat object.
DateTimeFormatInfo^ fmt = gcnew DateTimeFormatInfo;
// Insert code to set format.
DataGridTextBoxColumn^ myColumnTextColumn;
// Create the DataGridTextBoxColumn with the PropertyDescriptor and Format.
myColumnTextColumn = gcnew DataGridTextBoxColumn( pd,fmt->SortableDateTimePattern );
// Add the new DataGridColumnStyle to the GridColumnsCollection.
dataGrid1->TableStyles[ 0 ]->GridColumnStyles->Add( myColumnTextColumn );
}
private void AddColumn(DataTable myTable)
{
// Add a new DataColumn to the DataTable.
DataColumn myColumn = new DataColumn("myTextBoxColumn");
myColumn.set_DataType(String.class.ToType());
myColumn.set_DefaultValue("default string");
myTable.get_Columns().Add(myColumn);
// Get the ListManager for the DataTable.
CurrencyManager cM = (CurrencyManager)(this.get_BindingContext().
get_Item(myTable));
// Use the ListManager to get the PropertyDescriptor for the new column.
PropertyDescriptor pd = cM.GetItemProperties().get_Item("myTextBoxColumn");
// Create a new DataTimeFormat object.
DateTimeFormatInfo fMt = new DateTimeFormatInfo();
// Insert code to set format.
DataGridTextBoxColumn myColumnTextColumn;
// Create the DataGridTextBoxColumn with the PropertyDescriptor and Format.
myColumnTextColumn = new DataGridTextBoxColumn(pd, fMt.
get_SortableDateTimePattern());
// Add the new DataGridColumnStyle to the GridColumnsCollection.
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
Siehe auch
Referenz
DataGridTextBoxColumn-Klasse
DataGridTextBoxColumn-Member
System.Windows.Forms-Namespace
DataColumn
DataGridColumnStyle-Klasse
DataGrid-Klasse