ComboBoX..Items.Clear();值不在预期的范围内
//初始化收货客户集合
private void InitDealers(string CustomerSmplVch)
{
if (cbReceive.Items.Count > 0)
cbReceive.Items.Clear();
string strWhere = "";
if (!string.IsNullOrEmpty(CustomerSmplVch))
{
strWhere+=" CustomerSmplVch='"+CustomerSmplVch+"' ";
}
DataTable dt = dearBLL.GetList(strWhere);
DataRow dr = dt.NewRow();
dr["CustomerSmplVch"] = "0";
dr["DealerCodeVch"] = "0";
dr["DealerNameVch"] = "--请选择--";
dt.Rows.InsertAt(dr,0);
cbReceive.DataSource = dt.DefaultView;
cbReceive.ValueMember = "DealerCodeVch";
cbReceive.DisplayMember = "DealerNameVch";
}
给combobox赋值调用此方法后,想重新给Combobox赋值,再次调用此方法,可cbReceive.Items.Clear();报错“值不在预期的范围内。”为什么啊?请大家帮帮忙,谢谢了,在线等
------解决方案--------------------错误在哪一行出现
------解决方案-------------------- private void InitDealers(string CustomerSmplVch)