我使用.NET 2.0,並試圖將組合框的數據源綁定到已排序的字典。使用字典作爲數據源的綁定組合框
所以我得到的錯誤是「DataMember屬性」鍵「無法在數據源中找到」。
SortedDictionary<string, int> userCache = UserCache.getSortedUserValueCache();
userListComboBox.DataSource = new BindingSource(userCache, "Key"); //This line is causing the error
userListComboBox.DisplayMember = "Key";
userListComboBox.ValueMember = "Value";
那麼它不應該無論如何。但切換兩者可能更有意義。但是我遇到的問題是「comboBox1.DataSource = new BindingSource(userCache,null);」我不能在那裏拉空,因爲它給我一個錯誤。 – user803952
什麼錯誤,這實際上適用於我? –
「ArgumentException:無法綁定到新的顯示成員。參數名稱:newDisplayMember。」我不知道user803952得到了什麼錯誤,但是這是我用'IDictionary'嘗試這樣做時發生的錯誤。 –