1 out of 1 rated this helpful - Rate this topic

DataGridTextBoxColumn Class

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

System.Object
  System.MarshalByRefObject
    System.ComponentModel.Component
      System.Windows.Forms.DataGridColumnStyle
        System.Windows.Forms.DataGridTextBoxColumn

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)
public class DataGridTextBoxColumn : DataGridColumnStyle

The DataGridTextBoxColumn type exposes the following members.

  Name Description
Public method DataGridTextBoxColumn() Initializes a new instance of the DataGridTextBoxColumn class.
Public method DataGridTextBoxColumn(PropertyDescriptor) Initializes a new instance of a DataGridTextBoxColumn with a specified PropertyDescriptor.
Public method DataGridTextBoxColumn(PropertyDescriptor, Boolean) Initializes a new instance of the DataGridTextBoxColumn class using the specified PropertyDescriptor. Specifies whether the DataGridTextBoxColumn is a default column.
Public method DataGridTextBoxColumn(PropertyDescriptor, String) Initializes a new instance of a DataGridTextBoxColumn with the specified PropertyDescriptor and format.
Public method 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.
Top
  Name Description
Public property Alignment Gets or sets the alignment of text in a column. (Inherited from DataGridColumnStyle.)
Protected property CanRaiseEvents Gets a value indicating whether the component can raise an event. (Inherited from Component.)
Public property Container Gets the IContainer that contains the Component. (Inherited from Component.)
Public property DataGridTableStyle Gets the DataGridTableStyle for the column. (Inherited from DataGridColumnStyle.)
Protected property DesignMode Gets a value that indicates whether the Component is currently in design mode. (Inherited from Component.)
Protected property Events Gets the list of event handlers that are attached to this Component. (Inherited from Component.)
Protected property FontHeight Gets the height of the column's font. (Inherited from DataGridColumnStyle.)
Public property Format Gets or sets the character(s) that specify how text is formatted.
Public property FormatInfo Gets or sets the culture specific information used to determine how values are formatted.
Public property HeaderAccessibleObject Infrastructure. Gets the AccessibleObject for the column. (Inherited from DataGridColumnStyle.)
Public property HeaderText Gets or sets the text of the column header. (Inherited from DataGridColumnStyle.)
Public property MappingName Gets or sets the name of the data member to map the column style to. (Inherited from DataGridColumnStyle.)
Public property NullText Gets or sets the text that is displayed when the column contains null. (Inherited from DataGridColumnStyle.)
Public property PropertyDescriptor Gets or sets the PropertyDescriptor for the DataGridTextBoxColumn. (Overrides DataGridColumnStyle.PropertyDescriptor.)
Public property ReadOnly Sets a value indicating whether the text box column is read-only. (Overrides DataGridColumnStyle.ReadOnly.)
Public property Site Gets or sets the ISite of the Component. (Inherited from Component.)
Public property TextBox Gets the hosted TextBox control.
Public property Width Gets or sets the width of the column. (Inherited from DataGridColumnStyle.)
Top
  Name Description
Protected method Abort Initiates a request to interrupt an edit procedure. (Overrides DataGridColumnStyle.Abort(Int32).)
Protected method BeginUpdate Suspends the painting of the column until the EndUpdate method is called. (Inherited from DataGridColumnStyle.)
Protected method CheckValidDataSource Throws an exception if the System.Windows.Forms.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.)
Protected method ColumnStartedEditing Informs the System.Windows.Forms.DataGrid that the user has begun editing the column. (Inherited from DataGridColumnStyle.)
Protected method Commit Inititates a request to complete an editing procedure. (Overrides DataGridColumnStyle.Commit(CurrencyManager, Int32).)
Protected method ConcedeFocus Informs the column that the focus is being conceded. (Overrides DataGridColumnStyle.ConcedeFocus().)
Protected method CreateHeaderAccessibleObject Gets the AccessibleObject for the column. (Inherited from DataGridColumnStyle.)
Public method CreateObjRef Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)
Public method Dispose() Releases all resources used by the Component. (Inherited from Component.)
Protected method Dispose(Boolean) Releases the unmanaged resources used by the Component and optionally releases the managed resources. (Inherited from Component.)
Protected method Edit(CurrencyManager, Int32, Rectangle, Boolean) Prepares a cell for editing. (Inherited from DataGridColumnStyle.)
Protected method Edit(CurrencyManager, Int32, Rectangle, Boolean, String) Prepares the cell for editing using the specified CurrencyManager, row number, and Rectangle parameters. (Inherited from DataGridColumnStyle.)
Protected method Edit(CurrencyManager, Int32, Rectangle, Boolean, String, Boolean) Prepares a cell for editing. (Overrides DataGridColumnStyle.Edit(CurrencyManager, Int32, Rectangle, Boolean, String, Boolean).)
Protected method EndEdit Ends an edit operation on the DataGridColumnStyle.
Protected method EndUpdate Resumes the painting of columns suspended by calling the BeginUpdate method. (Inherited from DataGridColumnStyle.)
Protected method EnterNullValue Enters a Value in the column. (Overrides DataGridColumnStyle.EnterNullValue().)
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Releases unmanaged resources and performs other cleanup operations before the Component is reclaimed by garbage collection. (Inherited from Component.)
Protected method GetColumnValueAtRow Gets the value in the specified row from the specified CurrencyManager. (Inherited from DataGridColumnStyle.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetLifetimeService Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Protected method GetMinimumHeight Gets the height of a cell in a DataGridColumnStyle. (Overrides DataGridColumnStyle.GetMinimumHeight().)
Protected method GetPreferredHeight Gets the height to be used in for automatically resizing columns. (Overrides DataGridColumnStyle.GetPreferredHeight(Graphics, Object).)
Protected method GetPreferredSize Returns the optimum width and height of the cell in a specified row relative to the specified value. (Overrides DataGridColumnStyle.GetPreferredSize(Graphics, Object).)
Protected method GetService Returns an object that represents a service provided by the Component or by its Container. (Inherited from Component.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method HideEditBox Hides the DataGridTextBox control and moves the focus to the DataGrid control.
Public method InitializeLifetimeService Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Protected method Invalidate Redraws the column and causes a paint message to be sent to the control. (Inherited from DataGridColumnStyle.)
Protected method MemberwiseClone() Creates a shallow copy of the current Object. (Inherited from Object.)
Protected method MemberwiseClone(Boolean) Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.)
Protected method Paint(Graphics, Rectangle, CurrencyManager, Int32) Paints the a DataGridColumnStyle with the specified Graphics, Rectangle, CurrencyManager, and row number. (Overrides DataGridColumnStyle.Paint(Graphics, Rectangle, CurrencyManager, Int32).)
Protected method Paint(Graphics, Rectangle, CurrencyManager, Int32, Boolean) Paints a DataGridColumnStyle with the specified Graphics, Rectangle, CurrencyManager, row number, and alignment. (Overrides DataGridColumnStyle.Paint(Graphics, Rectangle, CurrencyManager, Int32, Boolean).)
Protected method Paint(Graphics, Rectangle, CurrencyManager, Int32, Brush, Brush, Boolean) Paints a DataGridColumnStyle with the specified Graphics, Rectangle, CurrencyManager, row number, Brush, and foreground color. (Overrides DataGridColumnStyle.Paint(Graphics, Rectangle, CurrencyManager, Int32, Brush, Brush, Boolean).)
Protected method PaintText(Graphics, Rectangle, String, Boolean) Draws the text and rectangle at the given location with the specified alignment.
Protected method PaintText(Graphics, Rectangle, String, Brush, Brush, Boolean) Draws the text and rectangle at the specified location with the specified colors and alignment.
Protected method ReleaseHostedControl Removes the reference that the DataGrid holds to the control used to edit data. (Overrides DataGridColumnStyle.ReleaseHostedControl().)
Public method ResetHeaderText Resets the HeaderText to its default value, null. (Inherited from DataGridColumnStyle.)
Protected method SetColumnValueAtRow Sets the value in a specified row with the value from a specified CurrencyManager. (Inherited from DataGridColumnStyle.)
Protected method SetDataGrid Sets the System.Windows.Forms.DataGrid control that this column belongs to. (Inherited from DataGridColumnStyle.)
Protected method SetDataGridInColumn Adds a TextBox control to the DataGrid control's Control.ControlCollection. (Overrides DataGridColumnStyle.SetDataGridInColumn(DataGrid).)
Public method ToString Returns a String containing the name of the Component, if any. This method should not be overridden. (Inherited from Component.)
Protected method UpdateUI Updates the user interface. (Overrides DataGridColumnStyle.UpdateUI(CurrencyManager, Int32, String).)
Top
  Name Description
Public event AlignmentChanged Occurs when the Alignment property value changes. (Inherited from DataGridColumnStyle.)
Public event Disposed Occurs when the component is disposed by a call to the Dispose method. (Inherited from Component.)
Public event FontChanged Occurs when the column's font changes. (Inherited from DataGridColumnStyle.)
Public event HeaderTextChanged Occurs when the HeaderText property value changes. (Inherited from DataGridColumnStyle.)
Public event MappingNameChanged Occurs when the MappingName value changes. (Inherited from DataGridColumnStyle.)
Public event NullTextChanged Occurs when the NullText value changes. (Inherited from DataGridColumnStyle.)
Public event PropertyDescriptorChanged Occurs when the PropertyDescriptor property value changes. (Inherited from DataGridColumnStyle.)
Public event ReadOnlyChanged Occurs when the ReadOnly property value changes. (Inherited from DataGridColumnStyle.)
Public event WidthChanged Occurs when the Width property value changes. (Inherited from DataGridColumnStyle.)
Top
  Name Description
Explicit interface implemetation Private method IDataGridColumnStyleEditingNotificationService.ColumnStartedEditing Informs the DataGrid control that the user has begun editing the column. (Inherited from DataGridColumnStyle.)
Top

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.

[Visual Basic]

Note Note

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

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= 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);
 }



.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ