public void ComboBoxBinding(ComboBox comboBox, string display, string value, string sql)
{
DataTable dt = new SQLHelper().DBDataTable(sql);
comboBox.DisplayMember = display;
comboBox.ValueMember = value;
comboBox.DataSource = dt;
}
public void ComboBoxAddBingding(ComboBox cmb,string display)//为comboBox添加额外数据
{
DataTable dt = (DataTable)cmb.DataSource;
DataRow dr = dt.NewRow();
dr[display] = "全部";
dt.Rows.InsertAt(dr, 0);
cmb.DataSource = dt;
cmb.DisplayMember = display;
cmb.SelectedIndex = 0;
}
ComboBox绑定数据源及添加额外数据
最新推荐文章于 2022-12-20 16:58:42 发布