Hosts a TBD control in a cell of a DataGridColumn for editing strings.
Object
Component
DataGridColumn
DataGridTextBoxColumn
[Visual Basic] Public Class DataGridTextBoxColumn Inherits DataGridColumn [C#] public class DataGridTextBoxColumn : DataGridColumn [C++] public __gc class DataGridTextBoxColumn : public DataGridColumn [JScript] public class DataGridTextBoxColumn extends DataGridColumn
The DataGridTextBoxColumn class derives from the abstract (in Visual Basic MustInherit) class TBD. At run time, the TBD hosts a TextBox control that allows users to edit text.
As a derived class, DataGridTextBoxColumn overrides the following methods: GetPreferredHeight, GetPreferredSize, GetMinimumHeight, Abort, Commit, Edit, KeyPress, and Paint.
Special properties added to the class include Edit, Font, Format, HideEditBox, and EndEdit. These properties allow you to access the hosted TextBox control and its attributes, and set the format for displaying values.
If you are creating a new DataGridTextBoxColumn, you must associate it with a DataColumn object--either one that already exists, or a new one--before adding it to the GridColumnsCollection through the Add method. To do this, set the System.WinForms.DataGridColumn.DataColumn property to the desired DataColumn object.
The DataType property of the associated DataColumn should be set to a data type that can logically be edited in a text box control. The following data types are automaticaly associated with a TBD: TBD, TBD, TBD, TBD, TBD, TBD, TBD, TBD, TBD, TBD, TBD, TBD, TBD, and SByte.
Note The following types are not supported by Visual Basic: TBD, TBD, TBD, TBD, and TimeSpan.
CAUTION Once a TBD is associated with a DataColumn, attempting to reset the System.WinForms.DataGridColumn.DataColumn property can produce unpredictable results.
Namespace: System.WinForms
Assembly: System.WinForms.dll
The following example creates a new DataColumn and sets its DataType property to a string value type. The TBD object is then added to the ColumnsCollection via the Columns property. Finally, a new DataGridTextBoxColumn is created, its System.WinForms.DataGridColumn.DataColumn property set to the new TBD, and the new DataGridTextBoxColumn added to the GridColumnsCollection.
[Visual Basic]
Private Sub MakeEditCol() Dim dc As New DataColumn Set dc.DataType = [type].GetType("System.String") dc.ColumnName = "myString" dc.DefaultValue = "Hello" DataGrid1.DataGridTable.DataTable.Columns.Add dc Dim dgeCol As DataGridTextBoxColumn Set dgeCol = New DataGridTextBoxColumn(dc) DataGrid1.GridColumns.Add dgecol End Sub
DataGridTextBoxColumn Members | System.WinForms Namespace | DataGridBoolColumn | DataGridColumn | DataColumn | DataType | DataGrid | TextBox