日期:2014-05-17  浏览次数:20809 次

checkedListBox1 填充过程出错,请帮助看一下!
每张单对应多个值,想将每张单子号从表中读出来,然后将 checkedListBox1(包含每张单取值范围) 其中数据比较,若相同
 则将其选中
string sql= " select pr from sd_tbl ";
  SqlDataReader sqlread = boperate.getread(sql);
  if (sqlread.HasRows)
  {
  while (sqlread.Read())
  {  

  string pr= sqlread["pr"].ToString().Trim();

  for (int i = 0; i < checkedListBox1.Items.Count; i++)
  {
  if(checkedListBox1.Items[i].ToString()==pr )

  { checkedListBox1.SetItemChecked(i,true ); }
  }
   
  }
  }

------解决方案--------------------
先把错误说清楚,然后自己调试
------解决方案--------------------
填充过程中有什么错误呢?