Specifies the appearance, text formatting, and behavior of a System.Windows.Forms.DataGrid control column. This class is abstract.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Thetype exposes the following members.
|Alignment||Gets or sets the alignment of text in a column.|
|CanRaiseEvents||Gets a value indicating whether the component can raise an event. (Inherited from Component.)|
|Container||Gets the IContainer that contains the Component. (Inherited from Component.)|
|DataGridTableStyle||Gets the DataGridTableStyle for the column.|
|DesignMode||Gets a value that indicates whether the Component is currently in design mode. (Inherited from Component.)|
|Events||Gets the list of event handlers that are attached to this Component. (Inherited from Component.)|
|FontHeight||Gets the height of the column's font.|
|HeaderAccessibleObject||Infrastructure. Gets the AccessibleObject for the column.|
|HeaderText||Gets or sets the text of the column header.|
|MappingName||Gets or sets the name of the data member to map the column style to.|
|NullText||Gets or sets the text that is displayed when the column contains a null reference (Nothing in Visual Basic).|
|PropertyDescriptor||Gets or sets the PropertyDescriptor that determines the attributes of data displayed by the .|
|ReadOnly||Gets or sets a value indicating whether the data in the column can be edited.|
|Site||Gets or sets the ISite of the Component. (Inherited from Component.)|
|Width||Gets or sets the width of the column.|
|Abort||When overridden in a derived class, initiates a request to interrupt an edit procedure.|
|BeginUpdate||Suspends the painting of the column until the EndUpdate method is called.|
|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.|
|ColumnStartedEditing||Informs the System.Windows.Forms.DataGrid that the user has begun editing the column.|
|Commit||When overridden in a derived class, initiates a request to complete an editing procedure.|
|ConcedeFocus||Notifies a column that it must relinquish the focus to the control it is hosting.|
|CreateHeaderAccessibleObject||Gets the AccessibleObject for the column.|
|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.)|
|Dispose()||Releases all resources used by the Component. (Inherited from Component.)|
|Dispose(Boolean)||Releases the unmanaged resources used by the Component and optionally releases the managed resources. (Inherited from Component.)|
|Edit(CurrencyManager, Int32, Rectangle, Boolean)||Prepares a cell for editing.|
|Edit(CurrencyManager, Int32, Rectangle, Boolean, String)||Prepares the cell for editing using the specified CurrencyManager, row number, and Rectangle parameters.|
|Edit(CurrencyManager, Int32, Rectangle, Boolean, String, Boolean)||When overridden in a deriving class, prepares a cell for editing.|
|EndUpdate||Resumes the painting of columns suspended by calling the BeginUpdate method.|
|EnterNullValue||Enters a DBNull.Value into the column.|
|Equals(Object)||Determines whether the specified Object is equal to the current Object. (Inherited from Object.)|
|Finalize||Releases unmanaged resources and performs other cleanup operations before the Component is reclaimed by garbage collection. (Inherited from Component.)|
|GetColumnValueAtRow||Gets the value in the specified row from the specified CurrencyManager.|
|GetHashCode||Serves as a hash function for a particular type. (Inherited from Object.)|
|GetLifetimeService||Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)|
|GetMinimumHeight||When overridden in a derived class, gets the minimum height of a row.|
|GetPreferredHeight||When overridden in a derived class, gets the height used for automatically resizing columns.|
|GetPreferredSize||When overridden in a derived class, gets the width and height of the specified value. The width and height are used when the user navigates to DataGridTableStyle using the .|
|GetService||Returns an object that represents a service provided by the Component or by its Container. (Inherited from Component.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|InitializeLifetimeService||Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)|
|Invalidate||Redraws the column and causes a paint message to be sent to the control.|
|MemberwiseClone()||Creates a shallow copy of the current Object. (Inherited from Object.)|
|MemberwiseClone(Boolean)||Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.)|
|Paint(Graphics, Rectangle, CurrencyManager, Int32)||Paints the with the specified Graphics, Rectangle, CurrencyManager, and row number.|
|Paint(Graphics, Rectangle, CurrencyManager, Int32, Boolean)||When overridden in a derived class, paints a with the specified Graphics, Rectangle, CurrencyManager, row number, and alignment.|
|Paint(Graphics, Rectangle, CurrencyManager, Int32, Brush, Brush, Boolean)||Paints a with the specified Graphics, Rectangle, CurrencyManager, row number, background color, foreground color, and alignment.|
|ReleaseHostedControl||Allows the column to free resources when the control it hosts is not needed.|
|ResetHeaderText||Resets the HeaderText to its default value, a null reference (Nothing in Visual Basic).|
|SetColumnValueAtRow||Sets the value in a specified row with the value from a specified CurrencyManager.|
|SetDataGrid||Sets the System.Windows.Forms.DataGrid control that this column belongs to.|
|SetDataGridInColumn||Sets the System.Windows.Forms.DataGrid for the column.|
|ToString||Returns a String containing the name of the Component, if any. This method should not be overridden. (Inherited from Component.)|
|UpdateUI||Updates the value of a specified row with the given text.|
|AlignmentChanged||Occurs when the Alignment property value changes.|
|Disposed||Occurs when the component is disposed by a call to the Dispose method. (Inherited from Component.)|
|FontChanged||Occurs when the column's font changes.|
|HeaderTextChanged||Occurs when the HeaderText property value changes.|
|MappingNameChanged||Occurs when the MappingName value changes.|
|NullTextChanged||Occurs when the NullText value changes.|
|PropertyDescriptorChanged||Occurs when the PropertyDescriptor property value changes.|
|ReadOnlyChanged||Occurs when the ReadOnly property value changes.|
|WidthChanged||Occurs when the Width property value changes.|
|IDataGridColumnStyleEditingNotificationService.ColumnStartedEditing||Informs the DataGrid control that the user has begun editing the column.|
The System.Windows.Forms.DataGrid control automatically creates a collection of objects for you when you set the DataSource property to an appropriate data source. The objects created actually are instances of one of the following classes that inherit from : DataGridBoolColumn or DataGridTextBoxColumn class.
To format the data display, set the Format property of the DataGridTextBoxColumn class to one of the formatting values. For more information about valid formatting values, see Formatting Types and Custom Date and Time Format Strings.
You can also create your own set of objects and add them to the GridColumnStylesCollection. When you do so, you must set the MappingName of each column style to the ColumnName of a DataColumn to synchronize the display of columns with the actual data.
Always create objects and add them to the GridColumnStylesCollection before adding DataGridTableStyle objects to the GridTableStylesCollection. When you add an empty DataGridTableStyle with a valid MappingName value to the collection, objects are automatically generated for you. Consequently, an exception will be thrown if you try to add new objects with duplicate MappingName values to the GridColumnStylesCollection.
When one of the derived classes is instantiated by a System.Windows.Forms.DataGrid control, the class created depends on the DataType of the DataColumn associated with the object. For example, a DataColumn with its DataType set to System.Boolean will be associated with a DataGridBoolColumn. To determine the type of any , use the GetType method.
To create your own column classes, you can inherit from . You might want to do this in order to create special columns that host controls, as exemplified by the DataGridTextBox class, which hosts the TextBox control. For example, you can host an Image control to show pictures in columns, or you can create your own user control to host in the column.
The functionality of the shouldn't be confused with that of the DataColumn. Whereas the DataColumn contains the properties and methods appropriate to creating a data table's schema, the contains the properties and methods related to the appearance of an individual column on the screen.
The class also allows you to specify the behavior of a column while its data is being changed. The BeginUpdate and EndUpdate methods temporarily suspend the drawing of the column while large updates are being made to the column's data. Without this functionality, every change in every cell of the grid would be immediately drawn; this could be distracting to the user and a performance liability.
Most of the properties and methods of the class are tailored to controlling a column's appearance. But a few, such as the GetColumnValueAtRow and SetColumnValueAtRow allow you to examine and change the value in a specified cell.Notes to Implementers
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.