ButtonColumn
Hosts a collection of DataGridViewButtonCell objects.
Last updated
Was this helpful?
Hosts a collection of DataGridViewButtonCell objects.
Last updated
Was this helpful?
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.