I have a DataGridView and I want in my grid a column having some cells that display a button and some cells that do not contain the button. In order to solve this problem I've added a DataGridViewButtonColumn and I've written this method that I call to add the rows to my column:
private void AttachNewRow(bool validRow)
{
DataGridViewRow newRow = GetNewRow();
if (validRow)
{
newRow.Cells["Info"].Value = "Click me";
}
else
{
// Here I would like to hide the button in the cell
newRow.Cells["Info"].Value = null;
}
}
The problem is that when I set the cell value to null I receive an exception. How can I display some of these cells without the button inside? Thank you