次の方法で共有


DataGridTextBoxColumn クラス

文字列の編集に使用する、 DataGridColumnStyle のセル内の TextBox コントロールを管理します。

この型のすべてのメンバの一覧については、DataGridTextBoxColumn メンバ を参照してください。

System.Object
   System.MarshalByRefObject
      System.ComponentModel.Component
         System.Windows.Forms.DataGridColumnStyle
            System.Windows.Forms.DataGridTextBoxColumn

Public Class DataGridTextBoxColumn
   Inherits DataGridColumnStyle
[C#]
public class DataGridTextBoxColumn : DataGridColumnStyle
[C++]
public __gc class DataGridTextBoxColumn : public
   DataGridColumnStyle
[JScript]
public class DataGridTextBoxColumn extends DataGridColumnStyle

スレッドセーフ

この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。

解説

DataGridTextBoxColumn クラスは、抽象 (Visual Basic では MustInherit) クラス DataGridColumnStyle から派生します。実行時に、 DataGridTextBoxColumn は、ユーザーがテキスト編集のために使用できる DataGridTextBox コントロールを管理します。

このクラスには、 Format および HideEditBox などの特殊なプロパティが追加されています。これらのプロパティを使用すると、管理対象の DataGridTextBox コントロールとその属性にアクセスし、値を表示するときに適用する書式を設定できます。

データ ソースが DataColumn オブジェクトを格納している DataTable である場合は、 DataColumnDataType プロパティに、テキスト ボックス コントロールで論理的に編集できるデータ型を設定する必要があります。 DataGridTextBoxColumn に自動的に関連付けられるデータ型は、 ByteDateTimeDecimalDoubleInt16Int32Int64UInt16UInt32UInt64Single 、および String です。

[Visual Basic] メモ    DateTimeUInt16UInt32UInt64TimeSpan の各データ型は、Visual Basic では完全にはサポートされていません。また、演算子は使用できません。

使用例

[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++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

名前空間: System.Windows.Forms

プラットフォーム: 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

アセンブリ: System.Windows.Forms (System.Windows.Forms.dll 内)

参照

DataGridTextBoxColumn メンバ | System.Windows.Forms 名前空間 | DataGridBoolColumn | DataGridColumnStyle | DataColumn | DataType | DataGrid | DataGridTextBox | TextBox