As you can see in this tutorial there are several ways to fill a DataGridView that contains a CheckBox Column with data. They are:
- Binding a List to a DataGridView having a bool property
- Binding a datatable to a DataGridView having a bool column
- Adding a checkbox column (DataGridViewCheckBoxColumn) to the DataGridView.
Ignoring the third one, there is a difference between the first two (and you can see it in the result screen in the tutorial).
When you use a List, you get what you want: A DataGridView with a column that has CheckBox columns
However if you use the second method (a datatable), you get a DataGridView with a column that has CheckBox columns but with an extra empty row!
You can see it in the Pic in the tutorial:
Not only that but if you check on the empty row checkbox you get another empty row and that could go forever.
This is obviously undesirable behavior. So far I have been using Lists and they work ok but I would like to use dataTables to fill the DataGridView. Is there a way to avoid having this undersirable behavior and just get the exact rows?