ButtonColumn

Hosts a collection of DataGridViewButtonCell objects.

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

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

The default sort mode for this column type is 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.

For a full list of properties, methods and events see the API documentation.

Last updated