datagridview delete calls DefaultValuesNeeded

  • Thread starter Thread starter mrstrong
  • Start date Start date
M

mrstrong

Gday,

I have a datagridview who's datasource is a view (from oracle) but it
has a couple of combo boxes in it that when changed updates the
underlying table that this view is based off.

Anyway, it seems to work fine, however when I delete a row, and there
is only one row it deletes fine however it calls the
"defaultvaluesneeded" method for the datagridview and creates new IDs
etc...

Then when I go to enter data in what appears to be the first row, it
does not create new ID's for this row which causes problems with
validation (cell validation method updates the underlying table) - and
I do not know what happens to the new row that was apparently created
when the "defaultvaluesneeded"
method was called after the delete...

Has anyone had this problem before or perhaps can show me the error of
my ways?

Thanks!

Peter
 
Had the same problem for datagridviews, that are bounded to a BindingSource. Manifests after deleting the last row in the datagridview - if a row is added by typing in values, not all cells have default values set. Effect is not related to column order or visibility; in my case, one integer column value was set, but another was not. A string value was also set ok. Maybe the bug related to the datatype - works one time for each datatype?

The problem was solved as follows: to set initial cell values, instead DatagridView.DefaultValuesNeeded event use BindingSource.AddingNew event. At least, it worked for me.

If there is a similar event for DataTable, it might also work.
 
Back
Top