I know this is an old problem... I have DataGridView that's bound directly to a generic List of custom objects. This is the event when the user clicks the "Add new row" button:
private void btnAddStation_Click(object sender, EventArgs e)
{
if (dgvStationConfiguration.DataSource != null && ((List<StationConfiguration>)dgvStationConfiguration.DataSource).Count > 0)
{
var stations = (List<StationConfiguration>)dgvStationConfiguration.DataSource;
stations.Add(new StationConfiguration(string.Empty, string.Empty, string.Empty, stations.Last().FolderName));
IsGridDirty = true;
}
}
but the new row doesn't show up. In the debugger, I see it's been added to the datasource, but I cannot force it to show.
I've tried the old hack of setting the datasource to null and back to the list again, but it messes up the order of my datagridview's columns.
I've also tried Refresh and EndEdit with no success.