This documentation is archived and is not being maintained.

DataGridTextBox Class

Represents a TextBox control that is hosted in a DataGridTextBoxColumn.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public class DataGridTextBox : TextBox

The DataGridTextBox and the DataGridTextBoxColumn work together so that users can directly edit values in a DataGrid control column. The DataGridTextBoxColumn derives from DataGridColumnStyle, and is designed to host the DataGridTextBox, which derives from the TextBox control.

In addition to the properties, events, and methods of the base control, you can call the KeyPress and KeyDown events with the OnKeyPress and OnMouseDown methods.

The following code example demonstrates how to get the DataGridTextBox hosted by a DataGridTextBoxColumn.

private void GetDataGridTextBox()
   // Gets the DataGridTextBoxColumn from the DataGrid control.
   DataGridTextBoxColumn myTextBoxColumn;
   // Assumes the CompanyName column is a DataGridTextBoxColumn.
    myTextBoxColumn = (DataGridTextBoxColumn)dataGrid1.
   // Gets the DataGridTextBox for the column.
   DataGridTextBox myGridTextBox;
   myGridTextBox = (DataGridTextBox) myTextBoxColumn.TextBox;


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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

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.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0