我的 Windows 表单中有一个数据绑定组合框,我通过函数 deptload() IN FORM LOAD 填充它
public void DeptcomboLoad()
{
DataTable dt = depttrans.getDeptName();
Cmb_Department.DataSource = dt;
Cmb_Department.DisplayMember = "DepartmentName"; //CHAR
Cmb_Department.ValueMember = "DepartmentPK"; //INT
}
现在,当一个部门的员工(比如 accounts DepartmentName="Accounts" , DepartmentPK=23 )登录时,我希望将 ComboBox 文本选择为“acounts”,当我去获取 ComboBox 的选定值时,我应该得到 23
我试过
Cmb_Department.selectedtext="Accounts"
Cmb_Department.Text="Accounts"
但它没有给出选定的值
谁能给个建议