DataGridTextBoxColumn DataGridTextBoxColumn DataGridTextBoxColumn DataGridTextBoxColumn Class

Definition

Hosts a TextBox control in a cell of a DataGridColumnStyle for editing strings.

public ref class DataGridTextBoxColumn : System::Windows::Forms::DataGridColumnStyle
public class DataGridTextBoxColumn : System.Windows.Forms.DataGridColumnStyle
type DataGridTextBoxColumn = class
    inherit DataGridColumnStyle
Public Class DataGridTextBoxColumn
Inherits DataGridColumnStyle
Inheritance

Examples

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

Remarks

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.

Note

The following types are not fully supported by Visual Basic: DateTime, UInt16, UInt32, UInt64, and TimeSpan. (Operators are not allowed.)

Constructors

DataGridTextBoxColumn() DataGridTextBoxColumn() DataGridTextBoxColumn() DataGridTextBoxColumn()

Initializes a new instance of the DataGridTextBoxColumn class.

DataGridTextBoxColumn(PropertyDescriptor) DataGridTextBoxColumn(PropertyDescriptor) DataGridTextBoxColumn(PropertyDescriptor) DataGridTextBoxColumn(PropertyDescriptor)

Initializes a new instance of a DataGridTextBoxColumn with a specified PropertyDescriptor.

DataGridTextBoxColumn(PropertyDescriptor, Boolean) DataGridTextBoxColumn(PropertyDescriptor, Boolean) DataGridTextBoxColumn(PropertyDescriptor, Boolean) DataGridTextBoxColumn(PropertyDescriptor, Boolean)

Initializes a new instance of the DataGridTextBoxColumn class using the specified PropertyDescriptor. Specifies whether the DataGridTextBoxColumn is a default column.

DataGridTextBoxColumn(PropertyDescriptor, String) DataGridTextBoxColumn(PropertyDescriptor, String) DataGridTextBoxColumn(PropertyDescriptor, String) DataGridTextBoxColumn(PropertyDescriptor, String)

Initializes a new instance of a DataGridTextBoxColumn with the specified PropertyDescriptor and format.

DataGridTextBoxColumn(PropertyDescriptor, String, Boolean) DataGridTextBoxColumn(PropertyDescriptor, String, Boolean) DataGridTextBoxColumn(PropertyDescriptor, String, Boolean) DataGridTextBoxColumn(PropertyDescriptor, String, Boolean)

Initializes a new instance of the DataGridTextBoxColumn class with a specified PropertyDescriptor and format. Specifies whether the column is the default column.

Properties

Alignment Alignment Alignment Alignment

Gets or sets the alignment of text in a column.

(Inherited from DataGridColumnStyle)
CanRaiseEvents CanRaiseEvents CanRaiseEvents CanRaiseEvents

Gets a value indicating whether the component can raise an event.

(Inherited from Component)
Container Container Container Container

Gets the IContainer that contains the Component.

(Inherited from Component)
DataGridTableStyle DataGridTableStyle DataGridTableStyle DataGridTableStyle

Gets the DataGridTableStyle for the column.

(Inherited from DataGridColumnStyle)
DesignMode DesignMode DesignMode DesignMode

Gets a value that indicates whether the Component is currently in design mode.

(Inherited from Component)
Events Events Events Events

Gets the list of event handlers that are attached to this Component.

(Inherited from Component)
FontHeight FontHeight FontHeight FontHeight

Gets the height of the column's font.

(Inherited from DataGridColumnStyle)
Format Format Format Format

Gets or sets the character(s) that specify how text is formatted.

FormatInfo FormatInfo FormatInfo FormatInfo

Gets or sets the culture specific information used to determine how values are formatted.

HeaderAccessibleObject HeaderAccessibleObject HeaderAccessibleObject HeaderAccessibleObject

Gets the AccessibleObject for the column.

(Inherited from DataGridColumnStyle)
HeaderText HeaderText HeaderText HeaderText

Gets or sets the text of the column header.

(Inherited from DataGridColumnStyle)
MappingName MappingName MappingName MappingName

Gets or sets the name of the data member to map the column style to.

(Inherited from DataGridColumnStyle)
NullText NullText NullText NullText

Gets or sets the text that is displayed when the column contains null.

(Inherited from DataGridColumnStyle)
PropertyDescriptor PropertyDescriptor PropertyDescriptor PropertyDescriptor

Gets or sets the PropertyDescriptor for the DataGridTextBoxColumn.

ReadOnly ReadOnly ReadOnly ReadOnly

Sets a value indicating whether the text box column is read-only.

Site Site Site Site

Gets or sets the ISite of the Component.

(Inherited from Component)
TextBox TextBox TextBox TextBox

Gets the hosted TextBox control.

Width Width Width Width

Gets or sets the width of the column.

(Inherited from DataGridColumnStyle)

Methods

Abort(Int32) Abort(Int32) Abort(Int32) Abort(Int32)

Initiates a request to interrupt an edit procedure.

BeginUpdate() BeginUpdate() BeginUpdate() BeginUpdate()

Suspends the painting of the column until the EndUpdate() method is called.

(Inherited from DataGridColumnStyle)
CheckValidDataSource(CurrencyManager) CheckValidDataSource(CurrencyManager) CheckValidDataSource(CurrencyManager) CheckValidDataSource(CurrencyManager)

Throws an exception if the DataGrid does not have a valid data source, or if this column is not mapped to a valid property in the data source.

(Inherited from DataGridColumnStyle)
ColumnStartedEditing(Control) ColumnStartedEditing(Control) ColumnStartedEditing(Control) ColumnStartedEditing(Control)

Informs the DataGrid that the user has begun editing the column.

(Inherited from DataGridColumnStyle)
Commit(CurrencyManager, Int32) Commit(CurrencyManager, Int32) Commit(CurrencyManager, Int32) Commit(CurrencyManager, Int32)

Initiates a request to complete an editing procedure.

ConcedeFocus() ConcedeFocus() ConcedeFocus() ConcedeFocus()

Informs the column that the focus is being conceded.

CreateHeaderAccessibleObject() CreateHeaderAccessibleObject() CreateHeaderAccessibleObject() CreateHeaderAccessibleObject()

Gets the AccessibleObject for the column.

(Inherited from DataGridColumnStyle)
CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Dispose() Dispose() Dispose() Dispose()

Releases all resources used by the Component.

(Inherited from Component)
Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

Releases the unmanaged resources used by the Component and optionally releases the managed resources.

(Inherited from Component)
Edit(CurrencyManager, Int32, Rectangle, Boolean) Edit(CurrencyManager, Int32, Rectangle, Boolean) Edit(CurrencyManager, Int32, Rectangle, Boolean) Edit(CurrencyManager, Int32, Rectangle, Boolean)

Prepares a cell for editing.

(Inherited from DataGridColumnStyle)
Edit(CurrencyManager, Int32, Rectangle, Boolean, String) Edit(CurrencyManager, Int32, Rectangle, Boolean, String) Edit(CurrencyManager, Int32, Rectangle, Boolean, String) Edit(CurrencyManager, Int32, Rectangle, Boolean, String)

Prepares the cell for editing using the specified CurrencyManager, row number, and Rectangle parameters.

(Inherited from DataGridColumnStyle)
Edit(CurrencyManager, Int32, Rectangle, Boolean, String, Boolean) Edit(CurrencyManager, Int32, Rectangle, Boolean, String, Boolean) Edit(CurrencyManager, Int32, Rectangle, Boolean, String, Boolean) Edit(CurrencyManager, Int32, Rectangle, Boolean, String, Boolean)

Prepares a cell for editing.

EndEdit() EndEdit() EndEdit() EndEdit()

Ends an edit operation on the DataGridColumnStyle.

EndUpdate() EndUpdate() EndUpdate() EndUpdate()

Resumes the painting of columns suspended by calling the BeginUpdate() method.

(Inherited from DataGridColumnStyle)
EnterNullValue() EnterNullValue() EnterNullValue() EnterNullValue()

Enters a Value in the column.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetColumnValueAtRow(CurrencyManager, Int32) GetColumnValueAtRow(CurrencyManager, Int32) GetColumnValueAtRow(CurrencyManager, Int32) GetColumnValueAtRow(CurrencyManager, Int32)

Gets the value in the specified row from the specified CurrencyManager.

(Inherited from DataGridColumnStyle)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetMinimumHeight() GetMinimumHeight() GetMinimumHeight() GetMinimumHeight()

Gets the height of a cell in a DataGridColumnStyle.

GetPreferredHeight(Graphics, Object) GetPreferredHeight(Graphics, Object) GetPreferredHeight(Graphics, Object) GetPreferredHeight(Graphics, Object)

Gets the height to be used in for automatically resizing columns.

GetPreferredSize(Graphics, Object) GetPreferredSize(Graphics, Object) GetPreferredSize(Graphics, Object) GetPreferredSize(Graphics, Object)

Returns the optimum width and height of the cell in a specified row relative to the specified value.

GetService(Type) GetService(Type) GetService(Type) GetService(Type)

Returns an object that represents a service provided by the Component or by its Container.

(Inherited from Component)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
HideEditBox() HideEditBox() HideEditBox() HideEditBox()

Hides the DataGridTextBox control and moves the focus to the DataGrid control.

InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
Invalidate() Invalidate() Invalidate() Invalidate()

Redraws the column and causes a paint message to be sent to the control.

(Inherited from DataGridColumnStyle)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
Paint(Graphics, Rectangle, CurrencyManager, Int32) Paint(Graphics, Rectangle, CurrencyManager, Int32) Paint(Graphics, Rectangle, CurrencyManager, Int32) Paint(Graphics, Rectangle, CurrencyManager, Int32)

Paints the a DataGridColumnStyle with the specified Graphics, Rectangle, CurrencyManager, and row number.

Paint(Graphics, Rectangle, CurrencyManager, Int32, Boolean) Paint(Graphics, Rectangle, CurrencyManager, Int32, Boolean) Paint(Graphics, Rectangle, CurrencyManager, Int32, Boolean) Paint(Graphics, Rectangle, CurrencyManager, Int32, Boolean)

Paints a DataGridColumnStyle with the specified Graphics, Rectangle, CurrencyManager, row number, and alignment.

Paint(Graphics, Rectangle, CurrencyManager, Int32, Brush, Brush, Boolean) Paint(Graphics, Rectangle, CurrencyManager, Int32, Brush, Brush, Boolean) Paint(Graphics, Rectangle, CurrencyManager, Int32, Brush, Brush, Boolean) Paint(Graphics, Rectangle, CurrencyManager, Int32, Brush, Brush, Boolean)

Paints a DataGridColumnStyle with the specified Graphics, Rectangle, CurrencyManager, row number, Brush, and foreground color.

PaintText(Graphics, Rectangle, String, Boolean) PaintText(Graphics, Rectangle, String, Boolean) PaintText(Graphics, Rectangle, String, Boolean) PaintText(Graphics, Rectangle, String, Boolean)

Draws the text and rectangle at the given location with the specified alignment.

PaintText(Graphics, Rectangle, String, Brush, Brush, Boolean) PaintText(Graphics, Rectangle, String, Brush, Brush, Boolean) PaintText(Graphics, Rectangle, String, Brush, Brush, Boolean) PaintText(Graphics, Rectangle, String, Brush, Brush, Boolean)

Draws the text and rectangle at the specified location with the specified colors and alignment.

ReleaseHostedControl() ReleaseHostedControl() ReleaseHostedControl() ReleaseHostedControl()

Removes the reference that the DataGrid holds to the control used to edit data.

ResetHeaderText() ResetHeaderText() ResetHeaderText() ResetHeaderText()

Resets the HeaderText to its default value, null.

(Inherited from DataGridColumnStyle)
SetColumnValueAtRow(CurrencyManager, Int32, Object) SetColumnValueAtRow(CurrencyManager, Int32, Object) SetColumnValueAtRow(CurrencyManager, Int32, Object) SetColumnValueAtRow(CurrencyManager, Int32, Object)

Sets the value in a specified row with the value from a specified CurrencyManager.

(Inherited from DataGridColumnStyle)
SetDataGrid(DataGrid) SetDataGrid(DataGrid) SetDataGrid(DataGrid) SetDataGrid(DataGrid)

Sets the DataGrid control that this column belongs to.

(Inherited from DataGridColumnStyle)
SetDataGridInColumn(DataGrid) SetDataGridInColumn(DataGrid) SetDataGridInColumn(DataGrid) SetDataGridInColumn(DataGrid)

Adds a TextBox control to the DataGrid control's Control.ControlCollection.

ToString() ToString() ToString() ToString()

Returns a String containing the name of the Component, if any. This method should not be overridden.

(Inherited from Component)
UpdateUI(CurrencyManager, Int32, String) UpdateUI(CurrencyManager, Int32, String) UpdateUI(CurrencyManager, Int32, String) UpdateUI(CurrencyManager, Int32, String)

Updates the user interface.

Events

AlignmentChanged AlignmentChanged AlignmentChanged AlignmentChanged

Occurs when the Alignment property value changes.

(Inherited from DataGridColumnStyle)
Disposed Disposed Disposed Disposed

Occurs when the component is disposed by a call to the Dispose() method.

(Inherited from Component)
FontChanged FontChanged FontChanged FontChanged

Occurs when the column's font changes.

(Inherited from DataGridColumnStyle)
HeaderTextChanged HeaderTextChanged HeaderTextChanged HeaderTextChanged

Occurs when the HeaderText property value changes.

(Inherited from DataGridColumnStyle)
MappingNameChanged MappingNameChanged MappingNameChanged MappingNameChanged

Occurs when the MappingName value changes.

(Inherited from DataGridColumnStyle)
NullTextChanged NullTextChanged NullTextChanged NullTextChanged

Occurs when the NullText value changes.

(Inherited from DataGridColumnStyle)
PropertyDescriptorChanged PropertyDescriptorChanged PropertyDescriptorChanged PropertyDescriptorChanged

Occurs when the PropertyDescriptor property value changes.

(Inherited from DataGridColumnStyle)
ReadOnlyChanged ReadOnlyChanged ReadOnlyChanged ReadOnlyChanged

Occurs when the ReadOnly property value changes.

(Inherited from DataGridColumnStyle)
WidthChanged WidthChanged WidthChanged WidthChanged

Occurs when the Width property value changes.

(Inherited from DataGridColumnStyle)

Explicit Interface Implementations

IDataGridColumnStyleEditingNotificationService.ColumnStartedEditing(Control) IDataGridColumnStyleEditingNotificationService.ColumnStartedEditing(Control) IDataGridColumnStyleEditingNotificationService.ColumnStartedEditing(Control) IDataGridColumnStyleEditingNotificationService.ColumnStartedEditing(Control)

Informs the DataGrid control that the user has begun editing the column.

(Inherited from DataGridColumnStyle)

Applies to

See also