Export (0) Print
Expand All

DataGridTextBoxColumn Class

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

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

public class DataGridTextBoxColumn : DataGridColumnStyle

The DataGridTextBoxColumn type exposes the following members.

  NameDescription
Public methodDataGridTextBoxColumn()Initializes a new instance of the DataGridTextBoxColumn class.
Public methodDataGridTextBoxColumn(PropertyDescriptor)Initializes a new instance of a DataGridTextBoxColumn with a specified PropertyDescriptor.
Public methodDataGridTextBoxColumn(PropertyDescriptor, Boolean)Initializes a new instance of the DataGridTextBoxColumn class using the specified PropertyDescriptor. Specifies whether the DataGridTextBoxColumn is a default column.
Public methodDataGridTextBoxColumn(PropertyDescriptor, String)Initializes a new instance of a DataGridTextBoxColumn with the specified PropertyDescriptor and format.
Public methodDataGridTextBoxColumn(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

  NameDescription
Public propertyAlignmentGets or sets the alignment of text in a column. (Inherited from DataGridColumnStyle.)
Protected propertyCanRaiseEventsGets a value indicating whether the component can raise an event. (Inherited from Component.)
Public propertyContainerGets the IContainer that contains the Component. (Inherited from Component.)
Public propertyDataGridTableStyleGets the DataGridTableStyle for the column. (Inherited from DataGridColumnStyle.)
Protected propertyDesignModeGets a value that indicates whether the Component is currently in design mode. (Inherited from Component.)
Protected propertyEventsGets the list of event handlers that are attached to this Component. (Inherited from Component.)
Protected propertyFontHeightGets the height of the column's font. (Inherited from DataGridColumnStyle.)
Public propertyFormatGets or sets the character(s) that specify how text is formatted.
Public propertyFormatInfoGets or sets the culture specific information used to determine how values are formatted.
Public propertyHeaderAccessibleObjectInfrastructure. Gets the AccessibleObject for the column. (Inherited from DataGridColumnStyle.)
Public propertyHeaderTextGets or sets the text of the column header. (Inherited from DataGridColumnStyle.)
Public propertyMappingNameGets or sets the name of the data member to map the column style to. (Inherited from DataGridColumnStyle.)
Public propertyNullTextGets or sets the text that is displayed when the column contains null. (Inherited from DataGridColumnStyle.)
Public propertyPropertyDescriptorGets or sets the PropertyDescriptor for the DataGridTextBoxColumn. (Overrides DataGridColumnStyle.PropertyDescriptor.)
Public propertyReadOnlySets a value indicating whether the text box column is read-only. (Overrides DataGridColumnStyle.ReadOnly.)
Public propertySiteGets or sets the ISite of the Component. (Inherited from Component.)
Public propertyTextBoxGets the hosted TextBox control.
Public propertyWidthGets or sets the width of the column. (Inherited from DataGridColumnStyle.)
Top

  NameDescription
Protected methodAbortInitiates a request to interrupt an edit procedure. (Overrides DataGridColumnStyle.Abort(Int32).)
Protected methodBeginUpdateSuspends the painting of the column until the EndUpdate method is called. (Inherited from DataGridColumnStyle.)
Protected methodCheckValidDataSourceThrows 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 methodColumnStartedEditingInforms the System.Windows.Forms.DataGrid that the user has begun editing the column. (Inherited from DataGridColumnStyle.)
Protected methodCommitInititates a request to complete an editing procedure. (Overrides DataGridColumnStyle.Commit(CurrencyManager, Int32).)
Protected methodConcedeFocusInforms the column that the focus is being conceded. (Overrides DataGridColumnStyle.ConcedeFocus().)
Protected methodCreateHeaderAccessibleObjectGets the AccessibleObject for the column. (Inherited from DataGridColumnStyle.)
Public methodCreateObjRefCreates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)
Public methodDispose()Releases all resources used by the Component. (Inherited from Component.)
Protected methodDispose(Boolean)Releases the unmanaged resources used by the Component and optionally releases the managed resources. (Inherited from Component.)
Protected methodEdit(CurrencyManager, Int32, Rectangle, Boolean)Prepares a cell for editing. (Inherited from DataGridColumnStyle.)
Protected methodEdit(CurrencyManager, Int32, Rectangle, Boolean, String)Prepares the cell for editing using the specified CurrencyManager, row number, and Rectangle parameters. (Inherited from DataGridColumnStyle.)
Protected methodEdit(CurrencyManager, Int32, Rectangle, Boolean, String, Boolean)Prepares a cell for editing. (Overrides DataGridColumnStyle.Edit(CurrencyManager, Int32, Rectangle, Boolean, String, Boolean).)
Protected methodEndEditEnds an edit operation on the DataGridColumnStyle.
Protected methodEndUpdateResumes the painting of columns suspended by calling the BeginUpdate method. (Inherited from DataGridColumnStyle.)
Protected methodEnterNullValueEnters a Value in the column. (Overrides DataGridColumnStyle.EnterNullValue().)
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeReleases unmanaged resources and performs other cleanup operations before the Component is reclaimed by garbage collection. (Inherited from Component.)
Protected methodGetColumnValueAtRowGets the value in the specified row from the specified CurrencyManager. (Inherited from DataGridColumnStyle.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetLifetimeServiceRetrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Protected methodGetMinimumHeightGets the height of a cell in a DataGridColumnStyle. (Overrides DataGridColumnStyle.GetMinimumHeight().)
Protected methodGetPreferredHeightGets the height to be used in for automatically resizing columns. (Overrides DataGridColumnStyle.GetPreferredHeight(Graphics, Object).)
Protected methodGetPreferredSizeReturns the optimum width and height of the cell in a specified row relative to the specified value. (Overrides DataGridColumnStyle.GetPreferredSize(Graphics, Object).)
Protected methodGetServiceReturns an object that represents a service provided by the Component or by its Container. (Inherited from Component.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodHideEditBoxHides the DataGridTextBox control and moves the focus to the DataGrid control.
Public methodInitializeLifetimeServiceObtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Protected methodInvalidateRedraws the column and causes a paint message to be sent to the control. (Inherited from DataGridColumnStyle.)
Protected methodMemberwiseClone()Creates a shallow copy of the current Object. (Inherited from Object.)
Protected methodMemberwiseClone(Boolean)Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.)
Protected methodPaint(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 methodPaint(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 methodPaint(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 methodPaintText(Graphics, Rectangle, String, Boolean)Draws the text and rectangle at the given location with the specified alignment.
Protected methodPaintText(Graphics, Rectangle, String, Brush, Brush, Boolean)Draws the text and rectangle at the specified location with the specified colors and alignment.
Protected methodReleaseHostedControlRemoves the reference that the DataGrid holds to the control used to edit data. (Overrides DataGridColumnStyle.ReleaseHostedControl().)
Public methodResetHeaderTextResets the HeaderText to its default value, null. (Inherited from DataGridColumnStyle.)
Protected methodSetColumnValueAtRowSets the value in a specified row with the value from a specified CurrencyManager. (Inherited from DataGridColumnStyle.)
Protected methodSetDataGridSets the System.Windows.Forms.DataGrid control that this column belongs to. (Inherited from DataGridColumnStyle.)
Protected methodSetDataGridInColumnAdds a TextBox control to the DataGrid control's Control.ControlCollection. (Overrides DataGridColumnStyle.SetDataGridInColumn(DataGrid).)
Public methodToStringReturns a String containing the name of the Component, if any. This method should not be overridden. (Inherited from Component.)
Protected methodUpdateUIUpdates the user interface. (Overrides DataGridColumnStyle.UpdateUI(CurrencyManager, Int32, String).)
Top

  NameDescription
Public eventAlignmentChangedOccurs when the Alignment property value changes. (Inherited from DataGridColumnStyle.)
Public eventDisposedOccurs when the component is disposed by a call to the Dispose method. (Inherited from Component.)
Public eventFontChangedOccurs when the column's font changes. (Inherited from DataGridColumnStyle.)
Public eventHeaderTextChangedOccurs when the HeaderText property value changes. (Inherited from DataGridColumnStyle.)
Public eventMappingNameChangedOccurs when the MappingName value changes. (Inherited from DataGridColumnStyle.)
Public eventNullTextChangedOccurs when the NullText value changes. (Inherited from DataGridColumnStyle.)
Public eventPropertyDescriptorChangedOccurs when the PropertyDescriptor property value changes. (Inherited from DataGridColumnStyle.)
Public eventReadOnlyChangedOccurs when the ReadOnly property value changes. (Inherited from DataGridColumnStyle.)
Public eventWidthChangedOccurs when the Width property value changes. (Inherited from DataGridColumnStyle.)
Top

  NameDescription
Explicit interface implemetationPrivate methodIDataGridColumnStyleEditingNotificationService.ColumnStartedEditingInforms 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]

NoteNote

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.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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.
Show:
© 2014 Microsoft