I'd like to add a button column dynamically to a DataGridView after it has been populated. The button column is visible after adding it, but when I try to loop through the DataGridView rows, I get a null for the button in each cell.
var buttonCol = new DataGridViewButtonColumn();
buttonCol.Name = "ButtonColumnName";
buttonCol.HeaderText = "Header";
buttonCol.Text = "Button Text";
dataGridView.Columns.Add(buttonCol);
foreach (DataGridViewRow row in dataGridView.Rows)
{
var button = (Button)row.Cells["ButtonColumnName"].Value;
// button is null here!
}