DataGridTextBoxColumn クラス
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)


DataGridTextBoxColumn クラスは、abstract クラスの DataGridColumnStyle から派生したものです。実行時に、DataGridTextBoxColumn は、ユーザーがテキスト編集のために使用できる DataGridTextBox コントロールをホストします。
このクラスには、Format および HideEditBox などの特殊なプロパティが追加されています。これらのプロパティを使用すると、ホスト対象の DataGridTextBox コントロールとその属性にアクセスし、値を表示するときに適用する書式を設定できます。
データ ソースが DataColumn オブジェクトを格納している DataTable である場合は、DataColumn の DataType プロパティに、テキスト ボックス コントロールで論理的に編集できるデータ型を設定する必要があります。DataGridTextBoxColumn に自動的に関連付けられるデータ型は、Byte、DateTime、Decimal、Double、Int16、Int32、Int64、UInt16、UInt32、UInt64、Single、および String です。
![]() |
---|
DateTime、UInt16、UInt32、UInt64、TimeSpan の各データ型は、Visual Basic では完全にはサポートされていません。また、演算子は使用できません。 |

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

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


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- DataGridTextBoxColumn クラスのページへのリンク