在Winform中由于DropDownList绑定后再DropDownList.Items.Insert就会出错的问题解决,我这里拿一个DataTable举例:

1 DataTable DT=new DataTable();//通过数据库或者别的方式给这个先赋值
2  DataRow DR = DT.NewRow();
3  object[] obj = {"0", "请选择","00-00","" };//要知道你的DT的DataRow的结构
4 DR.ItemArray = obj;
5 DT.Rows.InsertAt(DR, 0);//插入第一个位置

这样就相当于DropDownList.Items.Insert(0,"数据")的效果了

相关文章:

  • 2021-11-22
  • 2021-06-17
  • 2021-10-13
  • 2021-12-24
  • 2021-08-12
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-12
  • 2021-08-19
  • 2021-08-04
  • 2022-12-23
相关资源
相似解决方案