DataGridTextBoxColumn Class
Updated: September 2008
Hosts a TextBox control in a cell of a DataGridColumnStyle for editing strings.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
The DataGridTextBoxColumn class derives from the abstract class DataGridColumnStyle. At run time, the DataGridTextBoxColumn hosts a DataGridTextBox control that allows users to edit text.
Special properties added to the class include Format, and HideEditBox. These properties allow you to access the hosted DataGridTextBox control and its attributes, and set the format for displaying values.
If the data source is a DataTable containing DataColumn objects, the DataType property of the DataColumn should be set to a data type that can logically be edited in a text box control. The following data types are automatically associated with a DataGridTextBoxColumn : Byte, DateTime, Decimal, Double, Int16, Int32, Int64, UInt16, UInt32, UInt64, Single, and String.
[Visual Basic]
The following example creates a DataGridTextBoxColumn and adds it to the GridColumnStylesCollection of a DataGrid. To run this code example, paste it into a form that has a DataGrid named dataGrid1 and call it from the constructor of the Form.
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
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.DataGridColumnStyle
System.Windows.Forms.DataGridTextBoxColumn
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note: