2024-10-02 01:33:32
2024-10-02 00:36:35
List<int> selectedRowsIndex = new List<int>();
List<DataGridViewRow> selecteRows = new List<DataGridViewRow>();
foreach(DataGridViewRow r in this.dataGridView1.Rows)
{
foreach (DataGridViewCell c in r.Cells)
if (c.Selected && !selectedRowsIndex.Contains(c.RowIndex))
{
selectedRowsIndex.Add(c.RowIndex);
selecteRows.Add(r);
}
}
if (selectedRowsIndex.Count > 1)
{
if (MessageBox.Show("确定删除" + selectedRowsIndex.Count.ToString() + "行数据吗?", "删除前确认", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
foreach (DataGridViewRow r in selecteRows)
this.dataGridView1.Rows.Remove(r);
}
}
2024-10-02 02:18:31