Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

How to select whole row when user clicks one cell or consective/concurrent cells in a DataGridView

$
0
0

Hello.

I'm developing a C# application with a DataGridView using Visual Studio Community 2015,  .NET Framework 4.6.00081 on a Dell laptop.

When a user clicks a cell in a DataGridView, I would like my program to select the whole row of where the cell was clicked.  I tried this:

        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            dataGridView1.Rows[e.RowIndex].Selected = true;
        }

and it works fine if the user only selects one cell.  It does not work if the user selects consecutive/concurrent cells in different rows.

Does anybody know how I can select the complete row/rows of whatever cells a user clicks?

Any help would be gratefully appreciated.

Thanks,
Tony


Stop The World, I want To Get Off! ........... Life Isn't About Waiting For The Storm To Pass ... It's About Learning To Dance In The Rain.



Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>