此代码导致DataGridView grid
显示空行,尽管它有一列DataPropertyName
设置为“MyProp1”:
public class MyClass
{
public int MyProp1;
public int MyProp2;
public int MyProp3;
}
public class MyItems:IListSource
{
BindingList<MyClass> _items = new BindingList<MyClass>();
//..............................
//IListSource
public bool ContainsListCollection
{
get { return false; }
}
//IListSource
public System.Collections.IList GetList()
{
return _items;
}
}
MyItems i = new MyItems();
.............
//MyItems list is populated
.............
grid.DataSource = i;
有什么问题?
如果我用“MyProp1”列创建一个 DataTable,它的内容就会以正确的方式显示。