次の方法で共有


DataGridTextBoxColumn コンストラクタ ()

DataGridTextBoxColumn クラスの新しいインスタンスを初期化します。

Public Sub New()
[C#]
public DataGridTextBoxColumn();
[C++]
public: DataGridTextBoxColumn();
[JScript]
public function DataGridTextBoxColumn();

使用例

[Visual Basic, C#, C++] DataGridTextBoxColumn を作成し、 GridColumnStylesCollection コレクションに追加する例を次に示します。

 
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

[C#] 
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);
 }


[C++] 
private:
    void AddColumn() {
        DataTable __gc *myTable= new DataTable();
 
        // Add a new DataColumn to the DataTable.
        DataColumn __gc *myColumn = new DataColumn(S"myTextBoxColumn");
        myColumn->DataType = System::Type::GetType(S"System::String");
        myColumn->DefaultValue = S"default string";
        myTable->Columns->Add(myColumn);
        // Get the CurrencyManager for the DataTable.
        CurrencyManager __gc *cm = dynamic_cast<CurrencyManager *>(this->BindingContext->Item[myTable]);
        // Use the CurrencyManager to get the PropertyDescriptor for the new column.
        System::ComponentModel::PropertyDescriptor __gc *pd = cm->GetItemProperties()->Item[S"myTextBoxColumn"];
        DataGridTextBoxColumn __gc *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->Item[0]->GridColumnStyles->Add(myColumnTextColumn);
    };

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET

参照

DataGridTextBoxColumn クラス | DataGridTextBoxColumn メンバ | System.Windows.Forms 名前空間 | DataGridTextBoxColumn コンストラクタのオーバーロードの一覧 | DataColumn | DataGridColumnStyle | DataGrid