insert a blank item as a first item in ComboBox

  • Thread starter Thread starter zleug
  • Start date Start date
Z

zleug

Guest
Hi All.

I populate combobox by method

public static List<Department> GetDepartments()
{
List<Department> deptdg = new List<Department>();
using (Model1 context = new Model1())
{
var departments = context.DepartmentCorps.AsNoTracking().ToList();
foreach (var dt in departments)
{
Department info = new Department();
info.DepartmentId = dt.DepartmentId;
info.Department = dt.Department;
info.Description = dt.Description;

deptdg.Add(info);
}
}
return deptdg;
}

How to insert blank first item as a result to get when form will open ComboBox will display text:
"-- Select Department --"?

Thanks

Continue reading...
 
Back
Top