At my form, I have one control ComboBox. I want after databinding add text "Select". I try this
cbOperatorList.DataSource = operatorService.GetOperatorList();
cbOperatorList.Items.Insert(0, "Select");
But when I do this. I get exception what
Changing the collection of items is impossible if you set the property DataSource.
UPDATE
public BindingList<Operator> GetOperatorList(string filter = "")
{
return
new BindingList<Operator>(
this.operatorRepository.All.Where(
item => item.FirtsName.Contains(filter) || item.LastName.Contains(filter) || item.MiddleName.Contains(filter)).
ToList());
}
UPDATE
I fixed the problem, using this code
cbOperatorList.DataSource =
this.operatorService.GetOperatorList().Concat(new[] { new Operator { LastName = "Select", Id = 0 } }).OrderBy(
item => item.Id).ToList();