Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

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)

[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] 
[ComVisibleAttribute(true)] 
public class DataGridTextBox : TextBox
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ 
/** @attribute ComVisibleAttribute(true) */ 
public class DataGridTextBox extends TextBox
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) 
ComVisibleAttribute(true) 
public class DataGridTextBox extends 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.
   TableStyles[0].GridColumnStyles["CompanyName"];
   // Gets the DataGridTextBox for the column.
   DataGridTextBox myGridTextBox;
   myGridTextBox = (DataGridTextBox) myTextBoxColumn.TextBox;
}


private void GetDataGridTextBox()
{
    // Gets the DataGridTextBoxColumn from the DataGrid control.
    DataGridTextBoxColumn myTextBoxColumn;
    // Assumes the CompanyName column is a DataGridTextBoxColumn.
    myTextBoxColumn = (DataGridTextBoxColumn)
        (dataGrid1.get_TableStyles().get_Item(0).
        get_GridColumnStyles().get_Item("CompanyName"));
    // Gets the DataGridTextBox for the column.
    DataGridTextBox myGridTextBox;
    myGridTextBox = (DataGridTextBox)(myTextBoxColumn.get_TextBox());
} //GetDataGridTextBox

System.Object
   System.MarshalByRefObject
     System.ComponentModel.Component
       System.Windows.Forms.Control
         System.Windows.Forms.TextBoxBase
           System.Windows.Forms.TextBox
            System.Windows.Forms.DataGridTextBox
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 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

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.