我已经使用以下方法将几个StaffRole
文件插入到组合框中;使用IndexOf搜索组合框
for (int i=0; i < staffRoles.Count; i++)
{
user_Role_Combo.Items.Add(staffRoles[i]);
}
我想搜索的组合框中的特定元素的索引,使其显示加载时正确的元素,我这有,但它只是返回-1每次;
StaffRole sr = new StaffRole("",roleID);
int comboBoxID = user_Role_Combo.Items.IndexOf(sr);
我正在做这个正确的方式不?
取决于这是否是WPF或WinForms的 – 2012-02-28 14:22:39
请出示你的'StaffRole.Equals'方法。 – dasblinkenlight 2012-02-28 14:23:30
'user_Role_Combo'的类型是什么? – Shai 2012-02-28 14:23:45