Shane Courtrille
Shane Courtrille

Reputation: 14097

BindingList returns a null for NewObject in AddingNew event

I'm a bit confused about this. I have breakpoints in place that show the event raising with a null NewObject and THEN the constructor to the object the list holds get called. It seems like this is completely backwards to me but I can't see anything I can change.

Am I missing something or is this just really broken?

Upvotes: 2

Views: 536

Answers (1)

Ivan Ferić
Ivan Ferić

Reputation: 4763

I just checked it - it calls constructor only if you don't set the NewObject property so I'd say that it's not realy broken.

The event is actually designed for you to replace adding new object with the default constructor with something that makes sense for your application - for example:

  • add object with non-default constructor
  • add object with default constructor but with several other properties set / methods called
  • add object of derived type from the one used in the binding list

Upvotes: 4

Related Questions