Click here to Skip to main content
14,699,006 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi.. friends I'm using DataGridView in my window project I have a problem that there is automatically a row is select in it. I use DataGrid.ClearSelection() method, but it clear the current selection only and select the first row of DataGridView automatically. Would you plz help me how to tackled the above problem.

Thnks in Advance

Rathi
Posted
Updated 22-Jun-19 8:20am

Do you ever need a selected row? If not, I usually handle this by cheating and just setting the selected cell ForeColor and BackColor to the same color as an unselected cell. This way you just never see the highlight.

You can also change the selection mode if you want to change what gets highlighted...the whole row, the whole column, just a cell, etc. It might be that the ClearSelection method only works if the selection mode is set to CellSelect.

Hope this helps.

--I also found this:
http://manfred-ramoser.blogspot.com/2008/01/hide-selection-in-datagridview.html[^]
   
v2
The only thing that worked for me was this:

DataGridView1.CurrentRow.Selected = False 'Unhighlights all selected rows
   

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