开发者

BindingList returns a null for NewObject in AddingNew event

开发者 https://www.devze.com 2023-03-08 06:01 出处:网络
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 comp

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?


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
0

精彩评论

暂无评论...
验证码 换一张
取 消