I have a datagridview that is updated when the bindingsource is updated. After the last row that has actual data there should be an empty row. If the user selects a cell in this row they should be able to type data into that cell (as if it were a textbox).
I have set the "AllowUserToAddRows" property of the datagridview to "true"; this adds a blank row after the last row with data. However, when the user clicks the row, the cells are populated with the default value for the field (zero, in my case).
Since the properties that I have bound the datagridview columns to are of type double, it seems like I can not display any non numeric values.
So first, is it possible to either leave the cells blank or display an empty string when they are clicked. Second, how can I allow the user to enter data into certain cells?
Try using the CellFormatting event:
The Double type isn't great for comparisons. Consider using a Decimal type instead.
Trying to keep the cells "blank" for the new row until they were "touched" by the user requires hacking around with a flag on each cell of the new row, so here is an example using the Tag property:
This example is just testing the second column with is of the type Double.