开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜