制作 BindingList最少需要多少?在 VS 2008 设计器中可用
我在运行时将控件的数据源设置为 BindingList,效果很好。
但我更希望能够在设计器中看到这一点,这意味着我可以在设计时选择数据成员属性,而不必在运行时设置它们。
允许这样做的最低要求是什么?
I am setting the datasource of a control at runtime to BindingList which works fine.
But I would prefer if I could see this in the designer which would mean that I could select the datamember properties at design time, rather than having to set them at runtime also.
What is the minimum requirements to allow this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
那么,您必须执行以下操作:
添加新数据源(您可以选择您的类对象)
当您绑定到网格时或任何用户控件,它将创建 BindingSource(或者您可以使用现有的)。
然后您可以绑定您的 BindingList
只要您的类具有 public {get; , 属性内容它将在数据源和网格中可见(例如作为列)
在此处查看 MDSN 链接
Well you will have to do the following:
Add New Data Source ( and you can select your class object)
when you bind to grid or any user control, it will create BindingSource (or you can use existing one).
You can then bind your BindingList
As long as your class has public {get; } properties stuff it will be visible in Data Source and in your Grid (as columns for example)
See MDSN link here
虽然 anvarbek raupov 的答案更简单,但我最终所做的是谈论一个现有的工作类,该类实现了一些不必要的接口,并删除了一些部分,直到我得到如下内容。
Although the answer from anvarbek raupov is simplier, what I ended up doing was talking an existing working class which implemented a few unnessary interfaces and ripping bits out until I got down to something like the following.