下面的代碼工作正常:Simply IEnumerable <int> to List <KeyValuePair <int, int>>?
cboDay.DataSource = Enumerable.Range(1, 31).ToDictionary(x => x, x => x).ToList<KeyValuePair<int, int>>();
cboDay.ValueMember = "Key";
cboDay.DisplayMember = "Value";
但是,有沒有更好的方式來簡化轉換? (如消除ToDictionary
?)
拋出一個異常'Complex DataBinding接受IList或IListSource作爲數據源' –
@ Ivan-MarkDebono添加了'.ToList()' – fubo