绑定数据代码如下
if (ds != null && ds.Tables[0].Rows.Count > 0) //DataSet
{
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
this.comboBox2.ValueMember = ds.Tables[0].Rows[i]["dict_id"].ToString();//取其中一列
this.comboBox2.DisplayMember = ds.Tables[0].Rows[i]["dict_name"].ToString();//取其中一列
}
}现在想在combobox开头加一项,但用代码this.comboBox2.Items.Insert(0,"全部")或是this.comboBox2.Items.Add("全部"),都不成功。
请问如何解决?谢谢!
if (ds != null && ds.Tables[0].Rows.Count > 0) //DataSet
{
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
this.comboBox2.ValueMember = ds.Tables[0].Rows[i]["dict_id"].ToString();//取其中一列
this.comboBox2.DisplayMember = ds.Tables[0].Rows[i]["dict_name"].ToString();//取其中一列
}
}现在想在combobox开头加一项,但用代码this.comboBox2.Items.Insert(0,"全部")或是this.comboBox2.Items.Add("全部"),都不成功。
请问如何解决?谢谢!
郁闷了;
if (ds != null && ds.Tables[0].Rows.Count > 0) //DataSet
{
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
this.comboBox2.Items.Add(Convert.ToString(ds.Tables[0].Rows[i]["dict_id"]));//取其中一列
this.comboBox2.Items.Add(Convert.ToString(ds.Tables[0].Rows[i]["dict_name]));//取其中一列
}
}
this.Items.Add(0,new ListItem("全部",""));