title: How to disable Null image in DataGridView image column when populated from DataTable
body: <p>I have an existing application with a new requirement to show an image in a DataGridView cell to denote whether the record has a specific flag associated with it or not (not user editable, this comes from the DB).</p>
  
  <p>If there is a flag, I show the corresponding image, and if there's no flag, I want nothing to be shown in the column.</p>
  
  <p>The DataGridView columns weren't created in Visual Studio designer, or else this would easy.  I could just set the NullValue property on the column.  Instead the columns are created at runtime when all the data is loaded into a DataTable, and then a DataView is created from that DataTable, and then the DataGridView's Datasource is set to the DataView.</p>
  
  <p>I can't completely rewrite this, or else I'd just define the columns in VS Designer instead of this ridiculous way of just letting the columns be defined from the DataTable.  </p>
  
  <p>My question is then, how can I make it so the column with the Images shows nothing when the underlying data table has a null?</p>
  
  <p>Here's some pseudo C# to demonstrate what I mean.  Remember, I didn't write it to use two DataTables like this; it was that way when I had it handed to me, and I don't want to make drastic changes just to add a new column...</p>
  
  <pre><code>DataTable rawData = someMethodThatReturnsMyRawData();
  DataTable data = new DataTable();
  data.Columns.Add("Flags", typeof(Image));
  data.Columns.Add("SomeOtherColumn");
  
  foreach (DataRow rawDataRow in rawData.Rows)
  {
      DataRow dataRow = data.NewRow();
      bool hasFlagType1 = false;
      bool hasFlagType2 = false;
  
      if (rawDataRow["FlagType1ID"] != DBNull.Value)
      {
          hasFlagType1 = true;
      }
  
      if (rawDataRow["FlagType2ID"] != DBNull.Value)
      {
          hasFlagType2 = true;
      }
  
      if (hasFlagType1 &amp;&amp; hasFlagType2)
      {
          dataRow[0] = Properties.Resources.BothFlagsImage;
      }
      else if (hasFlagType1)
      {
          dataRow[0] = Properties.Resources.FlagType1Image;
      }
      else if (hasFlagType2)
      {
          dataRow[0] = Properties.Resources.FlagType2Image;
      }
      else
      {
          //If neither flag set, I don't want it to show anything,
          //but if I leave it as null, a little box with an X in it shows up
          //I could set it to some transparent GIF here, but that seems lame
      }
  
      dataRow[1] = rawDataRow["SomeOtherColumn"];
  
      data.Rows.Add(dataRow);        
  }
  
  DataView dv = new DataView(data, string.Empty, "SomeOtherColumn ASC", DataViewRowState.CurrentRows);
  
  this.emptyDataGridViewFromDesigner.DataSource = dv;
  
  // How can I modify the column "Flags" at this point to show nothing if the value is null?
  </code></pre>
  
  <p>EDIT: Here's a screenshot so you can see what I mean by the little box with an X - those are all nulls...</p>
  
  <p><img src="https://i.stack.imgur.com/DgwaD.png" alt="DataGridView with Null Images"></p>
  
  <p>Also, it has to be .NET 3.5, so if there's a solution in .NET 4.0 only, I'm out of luck.</p>