为什么我在 Combobox.SelectedValue 中有 null?SelectedItem 不为空,它是匿名对象。DisplayMember 工作正常。
var item1 =
new
{
Name = "some phrase1",
Value = 0
};
var item2 =
new
{
Name = "some phrase2",
Value = 1
};
_cmb = new ComboBox();
_cmb.Items.Add(item1);
_cmb.Items.Add(item2);
_cmb.DisplayMember = "Name";
_cmb.ValueMember = "Value";
//.....
//onchange method
{
var nulled = _cmb.SelectedValue //why it's null???
}