开发者

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

开发者 https://www.devze.com 2023-02-08 08:31 出处:网络
I have many classes sharing a interface.I have also created a BindingList consist of objects created from these classes.

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

精彩评论

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