Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

c# datagridview multiple row selection without control

    private List<int> 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);
        }
    }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #datagridview #multiple #row #selection #control
ADD COMMENT
Topic
Name
6+3 =