+ -
当前位置:首页 → 问答吧 → 在非绑定的DATAGRIDVIEW加入checkbox字段?

在非绑定的DATAGRIDVIEW加入checkbox字段?

时间:2011-12-28

来源:互联网

使用一个非数据绑定的DATAGRIDVIEW,在向它里添加行时,在行最后加一个checkbox型字段,如果这个checkbox被勾选,在触发删除事件时 就删除这一行,如果多行的checkbox被勾选,就删除多行。这个应该怎么写啊?
C# code

//向DGV添加行
  DataGridViewRow dr = new DataGridViewRow();
       
            foreach (DataGridViewColumn c in this.data_list.Columns)
            {
                dr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
            }
            
            dr.Cells[0].Value = t_1.Text;
            dr.Cells[1].Value = t_2.Text;
            dr.Cells[2].Value = t_3.Text;
            dr.Cells[3].Value = t_4.Text;
            dr.Cells[4].Value = t_5.Text;
            dr.Cells[5].Value = t_6.Text;
            dr.Cells[6].Value = t_7.Text;          
            this.data_list.Rows.Add(dr);

//删除DGV中的选中行,删除事件
this.data_list.Rows.Remove(this.data_list.CurrentRow);

作者: zln0118   发布时间: 2011-12-28

自己顶一下.

作者: zln0118   发布时间: 2011-12-28