score:2

Accepted answer

How about converting it to a list, then choosing the correct one from it. Since SelectedItem doesn't seem to work, you may want to try setting SelectedValue.

var productList = (from p in db.products
                   select new {
                      ProductId = p.ProductID,
                      Name = p.Name
                   }).ToList();

comboBox1.DataSource = productList;
comboBox1.DisplayMember = "Name";
comboBox1.ValueMember = "ProductId";
comboBox1.SelectedValue = 5;

score:0

This should do the trick

var list = (from p in db.products
              select new {
                             p.ProductId,
                             p.Name
                           }).ToList();
comboBox1.DataSource = list;
comboBox1.SelectedItem = list[0];

Related Articles