How to disable Null image in DataGridView image column when populated from DataTable

I figured this out...

Have to cast the column as a DataGridViewImageColumn, then set the DefaultCellStyle.NullValue for that column to null. From my example above, you'd do it like this...

((DataGridViewImageColumn)this.emptyDataGridViewFromDesigner.Columns["Flags"]).DefaultCellStyle.NullValue = null;

I guess I jumped the gun asking here, but hope this helps someone else sometime.


To fix whole grid, just add this code to Form constructor. (and change name of your dataGrid):

        Load += delegate
        {
            // remove default [x] image for data DataGridViewImageColumn columns
            foreach (var column in dataGridView1.Columns)
            {
                if (column is DataGridViewImageColumn)
                    (column as DataGridViewImageColumn).DefaultCellStyle.NullValue = null;
            }
        };

It's FAR easier to simply assign new Bitmap(1,1); to the cell's .Value property and move on. My app was throwing exceptions whenever I tried to assign NULL to the Cell's Value, even with the modified DefaultCellStyle.NullValue

Something like this works as intended, every time, without any hassles or arcane/obscure settings:

dataGridView1.Rows[index].Cells["CellName"].Value = isFlag ? Properties.Resources.FlagImage : new Bitmap(1,1);