Ejemplo n.º 1
0
 private void  除ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         List <int> idtrr = new List <int>();
         for (int i = this.dataGridView1.SelectedRows.Count; i > 0; i--)
         {
             if (dataGridView1.SelectedRows[i - 1].Cells[0].Value == null || dataGridView1.SelectedRows[i - 1].Cells[0].Value is DBNull)
             {
                 DataRowView drv = dataGridView1.SelectedRows[i - 1].DataBoundItem as DataRowView;
                 if (drv != null)
                 {
                     drv.Delete();
                     i = i - 1;
                 }
             }
             else
             {
                 idtrr.Add(Convert.ToInt32(dataGridView1.SelectedRows[i - 1].Cells[0].Value));
             }
         }
         cal.deleteKucun(idtrr);
         this.backgroundWorker1.RunWorkerAsync();
         JingDu form = new JingDu(this.backgroundWorker1, "删除中");// 显示进度条窗体
         form.ShowDialog(this);
         form.Close();
         MessageBox.Show("删除成功!");
         bindDatagridview();
         //comboBox1_SelectedIndexChanged(sender, e);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }