我有一本要以表格形式显示的字典。最简单的方法是什么?
最好我想显示一个控件,我可以在其中使用 int 值进行排序。我试过 DataGridView 但什么也没显示,我一定是做错了什么......
代码:
mDataGridView.DataSource = mWordCount;
/*Where mWordCount is the Dictionary<string, int> but nothing shows up. (It's a forms-app, not a web-app)*/
我有一本要以表格形式显示的字典。最简单的方法是什么?
最好我想显示一个控件,我可以在其中使用 int 值进行排序。我试过 DataGridView 但什么也没显示,我一定是做错了什么......
代码:
mDataGridView.DataSource = mWordCount;
/*Where mWordCount is the Dictionary<string, int> but nothing shows up. (It's a forms-app, not a web-app)*/
试试看mWordCount.ToList()会发生什么。
解释在这里:
DataGridView 类支持标准的 Windows 窗体数据绑定模型。这意味着数据源可以是实现以下接口之一的任何类型:
- 该
IList接口包括一维数组。IListSource接口,如和DataTable类DataSet。IBindingList接口,如类BindingList<(Of <(T>)>)。IBindingListView接口,如类BindingSource。