I have a gridview where I can select multiple rows by pressing a control key. Is it possible to achieve the same without pressing a control key.
I had to do this for a touch screen where I wanted multiselect on single click, without ugly check boxes. Why over complicate it, just keep a not of the Index'es
private List SelectedIndexs { get; set; }
Then add or remove them from the list as you click them... Then look through you datagrid and select the rows in the list.
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);
}
}