开发者

How to use BindingList of object of different classes sharing same interface as datasource of datagridview

I have many classes sharing a interface.I have also created a BindingList consist of objects created from these classes.

Now i want to use this binding list as a Datasource for a Datagridview.

would this work?c开发者_运维技巧an please someone give me some example.


Oh wait - can you just create a BindingList of IMyInterface ?

myList = new List<IMyInterface>();

myList.Add(new Foo());
myList.Add(new Bar());

myDataGridView.DataSource = myList;

Foo and Bar implement IMyInterface

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜