制作 BindingList最少需要多少?在 VS 2008 设计器中可用

发布于 2024-09-02 11:46:18 字数 122 浏览 4 评论 0原文

我在运行时将控件的数据源设置为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

玩物 2024-09-09 11:46:18

那么,您必须执行以下操作:

  • 添加新数据源(您可以选择您的类对象)

  • 当您绑定到网格时或任何用户控件,它将创建 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

打小就很酷 2024-09-09 11:46:18

虽然 anvarbek raupov 的答案更简单,但我最终所做的是谈论一个现有的工作类,该类实现了一些不必要的接口,并删除了一些部分,直到我得到如下内容。

[ToolboxItem(true)]
public class myClassList : BindingList<myClass> , IComponent 
{
    public event EventHandler Disposed;

    public ISite Site { get; set; }

    public void Dispose()
    {
    }
}

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.

[ToolboxItem(true)]
public class myClassList : BindingList<myClass> , IComponent 
{
    public event EventHandler Disposed;

    public ISite Site { get; set; }

    public void Dispose()
    {
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文