是否可以根据其值设置组合框的 selectedIndex ,而无需遍历数据源?
我这样设置数据源:
caseDBTableAdapters.usersTableAdapter usersAdapter = new caseDBTableAdapters.usersTableAdapter();
caseDB.usersDataTable users;
users = usersAdapter.GetUsers();
cbOwner.DisplayMember = "fullName";
cbOwner.ValueMember = "userId";
cbOwner.DataSource = users;
必须遍历表 fx 似乎不太优雅。通过做:
int counter = 0;
foreach (caseDB.usersRow usersRow in users)
{
if (usersRow.userId == selectedUser)
{
cbOwner.SelectedIndex = counter;
}
counter++;
}