Click here to Skip to main content
14,695,439 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to select multi row like selecting row by ctrl + row header click.

What I have tried:

private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }
            dataGridView1.MultiSelect = true;
            int inde = e.RowIndex;
            dataGridView1.Rows[inde].Selected = true;
           
        }
Posted
Updated 10-May-16 22:32pm
v2
Comments
Santosh Kokatnur 11-May-16 1:54am
   
Member 12242717 11-May-16 2:50am
   
That's not work for me... any another solution

You need to handle the CellValueChanged event instead of CellClick .
For reference
DataGridView multi selection C#
   
Go to Properties

Choose



public bool MultiSelect { get; set; }


MultiSelect = true and SelectionMode = cellSelect
   
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900