DataGridTextBoxColumn DataGridTextBoxColumn DataGridTextBoxColumn DataGridTextBoxColumn Constructors

Definition

Überlädt

DataGridTextBoxColumn() DataGridTextBoxColumn() DataGridTextBoxColumn()

Initialisiert eine neue Instanz der DataGridTextBoxColumn-Klasse.Initializes a new instance of the DataGridTextBoxColumn class.

DataGridTextBoxColumn(PropertyDescriptor) DataGridTextBoxColumn(PropertyDescriptor) DataGridTextBoxColumn(PropertyDescriptor) DataGridTextBoxColumn(PropertyDescriptor)

Initialisiert eine neue Instanz einer DataGridTextBoxColumn mit einem angegebenen PropertyDescriptor.Initializes a new instance of a DataGridTextBoxColumn with a specified PropertyDescriptor.

DataGridTextBoxColumn(PropertyDescriptor, Boolean) DataGridTextBoxColumn(PropertyDescriptor, Boolean) DataGridTextBoxColumn(PropertyDescriptor, Boolean) DataGridTextBoxColumn(PropertyDescriptor, Boolean)

Initialisiert eine neue Instanz der DataGridTextBoxColumn-Klasse mit dem angegebenen PropertyDescriptor.Initializes a new instance of the DataGridTextBoxColumn class using the specified PropertyDescriptor. Gibt an, ob es sich bei der DataGridTextBoxColumn um eine Standardspalte handelt.Specifies whether the DataGridTextBoxColumn is a default column.

DataGridTextBoxColumn(PropertyDescriptor, String) DataGridTextBoxColumn(PropertyDescriptor, String) DataGridTextBoxColumn(PropertyDescriptor, String) DataGridTextBoxColumn(PropertyDescriptor, String)

Initialisiert eine neue Instanz einer DataGridTextBoxColumn mit dem angegebenen PropertyDescriptor und Format.Initializes a new instance of a DataGridTextBoxColumn with the specified PropertyDescriptor and format.

DataGridTextBoxColumn(PropertyDescriptor, String, Boolean) DataGridTextBoxColumn(PropertyDescriptor, String, Boolean) DataGridTextBoxColumn(PropertyDescriptor, String, Boolean) DataGridTextBoxColumn(PropertyDescriptor, String, Boolean)

Initialisiert eine neue Instanz der DataGridTextBoxColumn-Klasse mit einem angegebenen PropertyDescriptor und Format.Initializes a new instance of the DataGridTextBoxColumn class with a specified PropertyDescriptor and format. Gibt an, ob die Spalte die Standardspalte ist.Specifies whether the column is the default column.

DataGridTextBoxColumn() DataGridTextBoxColumn() DataGridTextBoxColumn()

Initialisiert eine neue Instanz der DataGridTextBoxColumn-Klasse.Initializes a new instance of the DataGridTextBoxColumn class.

public:
 DataGridTextBoxColumn();
public DataGridTextBoxColumn ();
Public Sub New ()

Beispiele

Im folgenden Beispiel wird ein DataGridTextBoxColumn erstellt und der GridColumnStylesCollection -Auflistung hinzugefügt.The following example creates a DataGridTextBoxColumn and adds it to the GridColumnStylesCollection collection.

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.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 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
Siehe auch

DataGridTextBoxColumn(PropertyDescriptor) DataGridTextBoxColumn(PropertyDescriptor) DataGridTextBoxColumn(PropertyDescriptor) DataGridTextBoxColumn(PropertyDescriptor)

Initialisiert eine neue Instanz einer DataGridTextBoxColumn mit einem angegebenen PropertyDescriptor.Initializes a new instance of a DataGridTextBoxColumn with a specified PropertyDescriptor.

public:
 DataGridTextBoxColumn(System::ComponentModel::PropertyDescriptor ^ prop);
public DataGridTextBoxColumn (System.ComponentModel.PropertyDescriptor prop);
new System.Windows.Forms.DataGridTextBoxColumn : System.ComponentModel.PropertyDescriptor -> System.Windows.Forms.DataGridTextBoxColumn
Public Sub New (prop As PropertyDescriptor)

Parameter

prop
PropertyDescriptor PropertyDescriptor PropertyDescriptor PropertyDescriptor

Der PropertyDescriptor für die Spalte, die der DataGridTextBoxColumn zugeordnet wird.The PropertyDescriptor for the column with which the DataGridTextBoxColumn will be associated.

Beispiele

Im folgenden Beispiel wird ein DataGridTextBoxColumn erstellt und der GridColumnStylesCollection -Auflistung hinzugefügt.The following example creates a DataGridTextBoxColumn and adds it to the GridColumnStylesCollection collection.

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.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 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

Hinweise

Der DataGridColumnStyle verwendet einen PropertyDescriptor , um den Typ der in der Spalte angezeigten Daten zu bestimmen.The DataGridColumnStyle uses a PropertyDescriptor to determine the type of data displayed in the column. Um einen PropertyDescriptorCollectionzurückzugeben, verwenden GetItemProperties Sie die- BindingManagerBase Methode der-Klasse.To return a PropertyDescriptorCollection, use the GetItemProperties method of the BindingManagerBase class.

Siehe auch

DataGridTextBoxColumn(PropertyDescriptor, Boolean) DataGridTextBoxColumn(PropertyDescriptor, Boolean) DataGridTextBoxColumn(PropertyDescriptor, Boolean) DataGridTextBoxColumn(PropertyDescriptor, Boolean)

Initialisiert eine neue Instanz der DataGridTextBoxColumn-Klasse mit dem angegebenen PropertyDescriptor.Initializes a new instance of the DataGridTextBoxColumn class using the specified PropertyDescriptor. Gibt an, ob es sich bei der DataGridTextBoxColumn um eine Standardspalte handelt.Specifies whether the DataGridTextBoxColumn is a default column.

public:
 DataGridTextBoxColumn(System::ComponentModel::PropertyDescriptor ^ prop, bool isDefault);
public DataGridTextBoxColumn (System.ComponentModel.PropertyDescriptor prop, bool isDefault);
new System.Windows.Forms.DataGridTextBoxColumn : System.ComponentModel.PropertyDescriptor * bool -> System.Windows.Forms.DataGridTextBoxColumn
Public Sub New (prop As PropertyDescriptor, isDefault As Boolean)

Parameter

isDefault
Boolean Boolean Boolean Boolean

Gibt an, ob es sich bei der DataGridTextBoxColumn um eine Standardspalte handelt.Specifies whether the DataGridTextBoxColumn is a default column.

Hinweise

Der DataGridColumnStyle verwendet einen PropertyDescriptor , um den Typ der in der Spalte angezeigten Daten zu bestimmen.The DataGridColumnStyle uses a PropertyDescriptor to determine the type of data displayed in the column. Um einen PropertyDescriptorCollectionzurückzugeben, verwenden GetItemProperties Sie die- BindingManagerBase Methode der-Klasse.To return a PropertyDescriptorCollection, use the GetItemProperties method of the BindingManagerBase class.

DataGridTextBoxColumn(PropertyDescriptor, String) DataGridTextBoxColumn(PropertyDescriptor, String) DataGridTextBoxColumn(PropertyDescriptor, String) DataGridTextBoxColumn(PropertyDescriptor, String)

Initialisiert eine neue Instanz einer DataGridTextBoxColumn mit dem angegebenen PropertyDescriptor und Format.Initializes a new instance of a DataGridTextBoxColumn with the specified PropertyDescriptor and format.

public:
 DataGridTextBoxColumn(System::ComponentModel::PropertyDescriptor ^ prop, System::String ^ format);
public DataGridTextBoxColumn (System.ComponentModel.PropertyDescriptor prop, string format);
new System.Windows.Forms.DataGridTextBoxColumn : System.ComponentModel.PropertyDescriptor * string -> System.Windows.Forms.DataGridTextBoxColumn
Public Sub New (prop As PropertyDescriptor, format As String)

Parameter

prop
PropertyDescriptor PropertyDescriptor PropertyDescriptor PropertyDescriptor

Der PropertyDescriptor für die Spalte, die der DataGridTextBoxColumn zugeordnet wird.The PropertyDescriptor for the column with which the DataGridTextBoxColumn will be associated.

format
String String String String

Das zum Formatieren der Spaltenwerte verwendete Format.The format used to format the column values.

Beispiele

Im folgenden Codebeispiel wird die Verwendung dieses Members veranschaulicht.The following code example demonstrates the use of this member.

private:
   void MyAddCustomDataTableStyle()
   {
      // Get the currency manager for 'myDataSet'.
      CurrencyManager^ myCurrencyManger = dynamic_cast<CurrencyManager^>(this->BindingContext[ myDataSet ]);
      DataGridTableStyle^ myTableStyle = gcnew DataGridTableStyle;
      myTableStyle->MappingName = "Customers";
      PropertyDescriptor^ proprtyDescriptorName = myCurrencyManger->GetItemProperties()[ "CustName" ];
      DataGridColumnStyle^ myCustomerNameStyle = gcnew DataGridTextBoxColumn( proprtyDescriptorName );
      myCustomerNameStyle->MappingName = "custName";
      myCustomerNameStyle->HeaderText = "Customer Name";
      myTableStyle->GridColumnStyles->Add( myCustomerNameStyle );

      // Add style for 'Date' column.
      PropertyDescriptor^ myDateDescriptor = myCurrencyManger->GetItemProperties()[ "Date" ];

      // 'G' is for MM/dd/yyyy HH:mm:ss date format.
      DataGridColumnStyle^ myDateStyle = gcnew DataGridTextBoxColumn( myDateDescriptor,"G" );
      myDateStyle->MappingName = "Date";
      myDateStyle->HeaderText = "Date";
      myDateStyle->Width = 150;
      myTableStyle->GridColumnStyles->Add( myDateStyle );

      // Add DataGridTableStyle instances to GridTableStylesCollection.
      myDataGrid->TableStyles->Add( myTableStyle );
   }

private void MyAddCustomDataTableStyle()
{
   // Get the currency manager for 'myDataSet'.
   CurrencyManager myCurrencyManger =
            (CurrencyManager)this.BindingContext[myDataSet];

   DataGridTableStyle myTableStyle = new DataGridTableStyle();
   myTableStyle.MappingName = "Customers";

   PropertyDescriptor proprtyDescriptorName =
            myCurrencyManger.GetItemProperties()["CustName"];

   DataGridColumnStyle myCustomerNameStyle =
            new DataGridTextBoxColumn(proprtyDescriptorName);

   myCustomerNameStyle.MappingName = "custName";
   myCustomerNameStyle.HeaderText = "Customer Name";
   myTableStyle.GridColumnStyles.Add(myCustomerNameStyle);

   // Add style for 'Date' column.
   PropertyDescriptor myDateDescriptor =
            myCurrencyManger.GetItemProperties()["Date"];
   // 'G' is for MM/dd/yyyy HH:mm:ss date format.
   DataGridColumnStyle myDateStyle =
            new DataGridTextBoxColumn(myDateDescriptor,"G");

   myDateStyle.MappingName = "Date";
   myDateStyle.HeaderText = "Date";
   myDateStyle.Width = 150;
   myTableStyle.GridColumnStyles.Add(myDateStyle);

   // Add DataGridTableStyle instances to GridTableStylesCollection.
   myDataGrid.TableStyles.Add(myTableStyle);
}

Private Sub MyAddCustomDataTableStyle()
   ' Get the currency manager for 'myDataSet'.
   Dim myCurrencyManger As CurrencyManager = CType(Me.BindingContext(myDataSet), CurrencyManager)
   
   Dim myTableStyle As New DataGridTableStyle()
   myTableStyle.MappingName = "Customers"
   
   Dim proprtyDescriptorName As PropertyDescriptor = myCurrencyManger.GetItemProperties()("CustName")
   
   Dim myCustomerNameStyle As DataGridTextBoxColumn = New DataGridTextBoxColumn(proprtyDescriptorName)
   
   myCustomerNameStyle.MappingName = "custName"
   myCustomerNameStyle.HeaderText = "Customer Name"
   myTableStyle.GridColumnStyles.Add(myCustomerNameStyle)
   
   ' Add style for 'Date' column.
   Dim myDateDescriptor As PropertyDescriptor = myCurrencyManger.GetItemProperties()("Date")
   ' 'G' is for MM/dd/yyyy HH:mm:ss date format.
   Dim myDateStyle As DataGridTextBoxColumn = New DataGridTextBoxColumn(myDateDescriptor, "G")
   
   myDateStyle.MappingName = "Date"
   myDateStyle.HeaderText = "Date"
   myDateStyle.Width = 150
   myTableStyle.GridColumnStyles.Add(myDateStyle)
   
   ' Add DataGridTableStyle instances to GridTableStylesCollection.
   myDataGrid.TableStyles.Add(myTableStyle)
End Sub


Hinweise

Verwenden Sie diesen Konstruktor, um ein benutzerdefiniertes Format für die angezeigten Daten zu erstellen.Use this constructor to create a custom format for the displayed data.

Der DataGridColumnStyle verwendet einen PropertyDescriptor , um den Typ der in der Spalte angezeigten Daten zu bestimmen.The DataGridColumnStyle uses a PropertyDescriptor to determine the type of data displayed in the column. Um einen PropertyDescriptorCollectionzurückzugeben, verwenden GetItemProperties Sie die- BindingManagerBase Methode der-Klasse.To return a PropertyDescriptorCollection, use the GetItemProperties method of the BindingManagerBase class.

Weitere Informationen zum Formatieren von Zeichen finden Sie unter Formatierungs Typen und benutzerdefinierte Format Zeichenfolgen für Datum und Uhrzeit.For more information about formatting characters, see Formatting Types and Custom Date and Time Format Strings.

Siehe auch

DataGridTextBoxColumn(PropertyDescriptor, String, Boolean) DataGridTextBoxColumn(PropertyDescriptor, String, Boolean) DataGridTextBoxColumn(PropertyDescriptor, String, Boolean) DataGridTextBoxColumn(PropertyDescriptor, String, Boolean)

Initialisiert eine neue Instanz der DataGridTextBoxColumn-Klasse mit einem angegebenen PropertyDescriptor und Format.Initializes a new instance of the DataGridTextBoxColumn class with a specified PropertyDescriptor and format. Gibt an, ob die Spalte die Standardspalte ist.Specifies whether the column is the default column.

public:
 DataGridTextBoxColumn(System::ComponentModel::PropertyDescriptor ^ prop, System::String ^ format, bool isDefault);
public DataGridTextBoxColumn (System.ComponentModel.PropertyDescriptor prop, string format, bool isDefault);
new System.Windows.Forms.DataGridTextBoxColumn : System.ComponentModel.PropertyDescriptor * string * bool -> System.Windows.Forms.DataGridTextBoxColumn
Public Sub New (prop As PropertyDescriptor, format As String, isDefault As Boolean)

Parameter

format
String String String String

Das verwendete Format.The format used.

isDefault
Boolean Boolean Boolean Boolean

Gibt an, ob die DataGridTextBoxColumn die Standardspalte ist.Specifies whether the DataGridTextBoxColumn is the default column.

Hinweise

Der DataGridColumnStyle verwendet einen PropertyDescriptor , um den Typ der in der Spalte angezeigten Daten zu bestimmen.The DataGridColumnStyle uses a PropertyDescriptor to determine the type of data displayed in the column. Um einen PropertyDescriptorCollectionzurückzugeben, verwenden GetItemProperties Sie die- BindingManagerBase Methode der-Klasse.To return a PropertyDescriptorCollection, use the GetItemProperties method of the BindingManagerBase class.

Gilt für: