System.Windows.Forms.DataGridViewButtonColumn Class

Hosts a collection of System.Windows.Forms.DataGridViewButtonCell objects.

See Also: DataGridViewButtonColumn Members

Syntax

[System.Drawing.ToolboxBitmap("")]
public class DataGridViewButtonColumn : DataGridViewColumn

Remarks

The System.Windows.Forms.DataGridViewButtonColumn class is a specialized type of the System.Windows.Forms.DataGridViewColumn class used to logically host cells that respond to simple user input. A System.Windows.Forms.DataGridViewButtonColumn has an associated System.Windows.Forms.DataGridViewButtonCell in every System.Windows.Forms.DataGridViewRow that intersects it. Each cell supplies a user interface (UI) that is similar to a System.Windows.Forms.Button control.

To display the same button text for every cell, set the DataGridViewButtonColumn.UseColumnTextForButtonValue property to true and set the DataGridViewButtonColumn.Text property to the desired button text.

The default sort mode for this column type is DataGridViewColumnSortMode.NotSortable.

To respond to user button clicks, handle the DataGridView.CellClick or DataGridView.CellContentClick event. In the event handler, you can use the DataGridViewCellEventArgs.ColumnIndex property to determine whether the click occurred in the button column. You can use the DataGridViewCellEventArgs.RowIndex property to determine whether the click occurred in a button cell and not on the column header.

Note:

When visual styles are enabled, the buttons in a button column are painted using a System.Windows.Forms.ButtonRenderer, and cell styles specified through properties such as DataGridViewButtonColumn.DefaultCellStyle have no effect.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0