Can't Set ComboBox.SelectedItem?
I have the following code:
var db = new db();
var temp =
db.Table.Where(a =>
a.id == 1);
if(temp.Any()) {
var listItem = temp.Select(a => new listItem(a)).Single();
comboBox.SelectedItem = listItem;
}
It 开发者_开发技巧runs to the line: comboBox.SelectedItem = listItem; and listItem does contain a value, but right after the line runs, comboBox.SelectedItem is still equal to null. I don't see how this is possible since listItem has a value, what could possibly be going wrong here?
You are creating a new ListItem
that does not exist in the CobmoBox
's items.
精彩评论