开发者

What is the minimum needed to make a BindingList<myClass> available in VS 2008 Designer

I am setting the datasource of开发者_StackOverflow 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?


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


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()
    {
    }
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜