此代碼會導致DataGridView grid
顯示空行,儘管它有一個柱DataPropertyName
設置爲「MyProp1」:的DataGridView必然的BindingList顯示空行
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,其內容以正確的方式顯示。
爲什麼'ContainsListCollection'在吸氣返回'FALSE'? –
你可以爲你的datagridview發佈XAML嗎? –
是「WPF」還是「WinForms」?如果你的集合元素是「IList」,那麼返回值必須是真的,否則爲false。 –