ComboBoxには、DataSourceプロパティで設定されたComboBoxがあるとします。 ComboBoxの各項目はカスタムオブジェクトで、ComboBoxはDisplayMember
とValueMember
に設定されています。DataSourceでComboBoxの項目を取得する
IList<CustomItem> aItems = new List<CustomItem>();
//CustomItem has Id and Value and is filled through its constructor
aItems.Add(1, "foo");
aItems.Add(2, "bar");
myComboBox.DataSource = aItems;
ここで問題は、UIで表示される文字列として項目を読み取ることです。 ComboBoxの各アイテムのタイプがわからないことを考慮してください(CustomItem
は私には分かりません)
これは可能ですか?
そのを。 –