<p>In Visual Studio 2008</p>

<ul>
<li>add a new DataGridView to a form</li>
<li>Edit Columns</li>
<li>Add a a new DataGridViewImageColumn</li>
<li>Open the CellStyle Builder of this column (DefaultCellStyle property)</li>
<li>Change the NullValue from System.Drawing.Bitmap to null</li>
<li>Try to add a new Row to the DataGridView at runtime
(dataGridView1.Rows.Add();)</li>
<li>You get this error: System.FormatException: Formatted
value of the cell has a wrong type.</li>
</ul>

<p>If you change back the NullValue to System.Drawing.Bitmap (as it was) you still get the same error at adding a row.</p>

<p>If you set the NullValue at runtime instead of designtime you don't get anny error. 
(dataGridView1.Columns[0].DefaultCellStyle.NullValue = null;)</p>

<p>Could you tell me why is that?</p>

[{'answer_id': 48296, 'author': 'ljs', 'author_id': 3394, 'author_profile': 'https://Stackoverflow.com/users/3394', 'pm_score': 3, 'selected': True, 'text': '<p>This may well be a bug in the designer; if you take a look around at the .designer.cs file (maybe doing a diff from before and after you set NullValue to null) you should be able to see the code it generates.</p>\n'}, {'answer_id': 48312, 'author': 'nandras', 'author_id': 4996, 'author_profile': 'https://Stackoverflow.com/users/4996', 'pm_score': 2, 'selected': False, 'text': '<p>Kronoz is right.\nAfter setting it at designtime it adds this to the .designer.cs:</p>\n\n<p>dataGridViewCellStyle1.NullValue = "null";</p>\n\n<p>If I modify <strong>"null"</strong> to <strong>null</strong> then it works fine. I checked the DataGridViewCellStyle.NullValue set_NullValue(Object) and get_NullValue with reflector and I think that a string value shouldn\'t raise any error here.</p>\n\n<p>Anyway be careful with this and if you want to set it designtime then don\'t forget to modify the .design.cs.</p>\n'}, {'answer_id': 326200, 'author': 'Thies', 'author_id': 41639, 'author_profile': 'https://Stackoverflow.com/users/41639', 'pm_score': 1, 'selected': False, 'text': '<blockquote>\n  <p>Change the NullValue from System.Drawing.Bitmap to null </p>\n</blockquote>\n\n<p>When you enter \'null\' into the field for NullValue in the Designer, you are specifing the string value "null". The only way to set NullValue to a non-string value is to set it programmatically or by modifing the designer code yourself.</p>\n'}, {'answer_id': 2130408, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': "<p>I found that its better if you just delete the item from the designer all together from the Format area and the default null value area. Then it sets it back to the real null. I'm going to try to set it in the init section away from the designer generated crap.</p>\n"}, {'answer_id': 7127068, 'author': 'VipX1', 'author_id': 753507, 'author_profile': 'https://Stackoverflow.com/users/753507', 'pm_score': 1, 'selected': False, 'text': '<p>Checkbox can\'t have a String value. \nDon\'t set any default value in the IDE properties dialog.\nI had "Empty" written into the RowsDefaultCellStyle.Format property and that caused the error. \nIt was self inflicted. As a fix I was trying to set the checkbox state to unchecked but I just needed to delete the string value.</p>\n'}]
['https://Stackoverflow.com/questions/48271', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4996/']