BindingList 在 AddingNew 事件中为 NewObject 返回 null
我对此有点困惑。我设置了断点,显示使用 null NewObject 引发的事件,然后调用列表保存的对象的构造函数。这对我来说似乎完全倒退了,但我看不出有什么可以改变的。
我错过了什么还是这真的坏了?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我刚刚检查过它 - 仅当您未设置 NewObject 属性时它才会调用构造函数,因此我想说它并没有真正损坏。
该事件实际上是为您设计的,用于将使用默认构造函数添加新对象替换为对您的应用程序有意义的内容 - 例如:
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: