Displays a button-like user interface (UI) for use in a System.Windows.Forms.DataGridView control.
See Also: DataGridViewButtonCell Members
The System.Windows.Forms.DataGridViewButtonCell class is a specialized type of System.Windows.Forms.DataGridViewCell used to display a button-like UI.
System.Windows.Forms.DataGridViewButtonColumn is the column type specialized to hold cells of this type. By default, the DataGridViewButtonColumn.CellTemplate is initialized to a new System.Windows.Forms.DataGridViewButtonCell. To pattern the cells within a column after an existing System.Windows.Forms.DataGridViewButtonCell, set the column's DataGridViewButtonColumn.CellTemplate property to the cell to use as a pattern.
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 a the button column. You can use the DataGridViewCellEventArgs.RowIndex property to determine whether the click occurred in a particular button cell.
The cell-related properties of the column are wrappers for the similarly-named properties of the template cell. Changing the property values of the template cell will affect only cells based on the template that are added after the change. Changing the cell-related property values of the column, however, will update the template cell and all other cells in the column, and refresh the column display if necessary.
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.