Eline Sami

Eline Sami

  • NA
  • 47
  • 70.4k

Select all rows in datagridview

Jul 21 2015 11:50 PM

Hello

In my windows form application, I have a datagridview where it is Not bound to a datasource.
I have one command button that enable me to select all the rows in the datagridview.

For example. If I have 150 rows in the dgv, then all the 150 rows should be selected and highlighted

Here is my code.


private void toolStripButton5_Click(object sender, EventArgs e)
        {
            dataGridView1.SelectAll();
            selectedAll = true;
}
The problem is that when I click the right mouse button to choose an option and change a value of all the selected rows from the context menu that I have, the selection will be gone and it will be
interrupted. (this means that only one row will be selected instead of all)

What can I do to keep all the rows selected and apply the changes to all selected rows?


Answers (2)