checkedlistbox 的 items 是表1 表2 表3 
数据库里面表是 T1 T2 T3怎么在 button1_Click 下实现选中那几个表就 delete from 表 选择的那几个表请高手指点

解决方案 »

  1.   

    换吧,用dataGridView很好实现,这个应该不能,没地方藏ID
      

  2.   

    你从CheckedListBox中选择了某些checkbox,记录下其text属性,再从数据库中,根据text查询那三个对应的表,删之,即可。
      

  3.   

    string str = "";
                foreach (object checkedItem in checkedListBox1.CheckedItems)
                {
                    str+=checkedItem.ToString()+",";
                }
                string[] aryOptions = str.Split(',');
                string s1 = aryOptions[0].ToString();
                string s2 = aryOptions[1].ToString();
                string s3 = aryOptions[2].ToString();
    在对 s1 s2 s3操作
      

  4.   

    我写个演示代码给你参考一下,让你有个直观的感受(由于时间紧,以下代码未经测试,并且大小写也不标准):
    //从checkedListBox中获取选中的checkbox的text属性:
    string s="";
    for(checkbox chb in checkboxlist.items)
    {
        if(chb.checked) s+=chb.Text+",";
    }string[] textArray=s.split(',');//接下来对数据库操作,找到指定的表,并删之
    for(int i=0;i<textArray.length;i++)
    {
         select from database where table.name=textArray[i].tostring();
    }