1) there is no Column #4: but, if that were true, you'd get an IndexOutOfRange error.
2) the ColumnType of Column #4 is not a standard (TextBox, Button, etc.) ColumnType, but, a custom Control. however, you imply that the user can edit that Column. is #4 a custom Column ? if yes, it needs a ToString implementation that will avoid failure trying to convert null.
so, having ruled out the most likely scenarios, you need to:
1) describe the versions of Visual Studio and C#/FrameWork you are using.
2) is the DataGridView the standard one provided in WinForms ?
TRY this with your DataGridView and look at the output:
when i want to debug a DataGridView, or build a string representation of all its rows/columns/values, i use this:
public string DGVToString(DataGridView dgv)
StringBuilder sb = new StringBuilder();
for (int i = 0; i < dataGridView1.Rows.Count; i++)
for (int j = 0; j < dataGridView1.Columns.Count; j++)
var value = dataGridView1.Rows[i].Cells[j].Value;
value = value == null ? "null" : value.ToString();
Note the use of StringBuilder to reduce the number of string allocations and build the output faster. Note the test for 'null that avoids an error when ToString is called on a null vak=lue