comboBox.DataSource = ds.Tables[0];
comboBox.DisplayMember = "name";
comboBox.ValueMember = "val";
comboBox.Items.Insert(0, "--请选择—");

这样出现:设置 DataSource 属性后无法修改项集合

方法:

DataTable dt = ds.Tables[0];
DataRow dr = dt.NewRow();
dr["name"] = "--选择所有--";
dt.Rows.InsertAt(dr, 0);

***********

comboBox.DataSource = ds.Tables[0]; 
comboBox.DisplayMember = "name";
comboBox.ValueMember = "val";

 

 

相关文章:

  • 2021-10-21
  • 2021-07-26
  • 2022-12-23
  • 2021-06-13
  • 2021-04-07
  • 2021-09-07
  • 2021-07-10
  • 2021-12-29
猜你喜欢
  • 2021-12-26
  • 2022-12-23
  • 2021-08-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-24
相关资源
相似解决方案