📜  c# datagridview 多行选择无控件 - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:50.881000             🧑  作者: Mango

代码示例1
private List SelectedIndexs { get; set; }
    private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
    {
        if (SelectedIndexs.Contains(e.RowIndex))
        {
            SelectedIndexs.Remove(e.RowIndex);
        }
        else
        {
            SelectedIndexs.Add(e.RowIndex);
        }

        foreach (DataGridViewRow row in this.dataGridView1.Rows)
        {
            row.Selected = SelectedIndexs.Contains(row.Index);
        }
    }