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

DataGridTextBox Class

Represents a TextBox control that is hosted in a DataGridTextBoxColumn.

For a list of all members of this type, see DataGridTextBox Members.

System.Object
   System.MarshalByRefObject
      System.ComponentModel.Component
         System.Windows.Forms.Control
            System.Windows.Forms.TextBoxBase
               System.Windows.Forms.TextBox
                  System.Windows.Forms.DataGridTextBox

[Visual Basic]
Public Class DataGridTextBox
   Inherits TextBox
[C#]
public class DataGridTextBox : TextBox
[C++]
public __gc class DataGridTextBox : public TextBox
[JScript]
public class DataGridTextBox extends TextBox

Thread Safety

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

Remarks

The DataGridTextBox and the DataGridTextBoxColumn work together to allow users to 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.

Example

[Visual Basic, C#, C++] The following example returns the DataGridTextBox hosted by a DataGridTextBoxColumn.

[Visual Basic] 
Private Sub GetDataGridTextBox()
    ' Gets the DataGridTextBoxColumn from the DataGrid control.
    Dim myTextBoxColumn As DataGridTextBoxColumn
    ' Assumes the CompanyName column is a DataGridTextBoxColumn.
    myTextBoxColumn = CType(dataGrid1.TableStyles(0). _
        GridColumnStyles("CompanyName"), DataGridTextBoxColumn)
    ' Gets the DataGridTextBox for the column.
    Dim myGridTextBox As DataGridTextBox
    myGridTextBox = CType(myTextBoxColumn.TextBox, DataGridTextBox)
End Sub

[C#] 
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;
}


[C++] 
private:
    void GetDataGridTextBox() {
        // Get the DataGridTextBoxColumn from the DataGrid control.
        DataGridTextBoxColumn __gc *myTextBoxColumn;
        // Assuming the CompanyName column is a DataGridTextBoxColumn.
        myTextBoxColumn = dynamic_cast<DataGridTextBoxColumn *>(dataGrid1->TableStyles->Item[0]->GridColumnStyles->Item[S"CompanyName"]);
        // Get the DataGridTextBox for the column.
        DataGridTextBox __gc *myGridTextBox;
        myGridTextBox = dynamic_cast<DataGridTextBox *>(myTextBoxColumn->TextBox);
    };

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Windows.Forms

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

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

See Also

DataGridTextBox Members | System.Windows.Forms Namespace

Show:
© 2014 Microsoft. All rights reserved.