I have a large DataGridView control that has several cells most of which contain a button. How can I change the color of those buttons?
This changes the "outline" of the button but not the button itself.
row.Cells[2].Style.BackColor = System.Drawing.Color.Red;
This doesn't seem to change anything that's visible:
row.Cells[2].Style.ForeColor = System.Drawing.Color.Red;
If it's not possible to change the background, is it possible to change the font on the button?
Using .NET 2.0.
The default button in a DataGridView is drawn using the ButtonRenderer which makes it quite difficult to override. if I were you, I'd just set the button FlatStyle to "Popup".
DataGridViewButtonCell buttonCell = (DataGridViewButtonCell)dataGridMappings.Rows[0].Cells[0];
buttonCell.FlatStyle = FlatStyle.Popup;
buttonCell.Style.BackColor = System.Drawing.Color.Red;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With