When I open my form that contains a DataViewGrid the first row is always automatically highlighted in blue showing that it is selected.
If I use


the highlighting disappears and the row "appears" to be unselected but when I check with

Me.DataGridView.CurrentRow.Index the value returned indicates that the row is still selected, just the highlighting has disappeared.

What is the correct method to deselect a selection?........and
What is the correct method to check that a row has been selected?

(I am hoping to code a button that checks if a selection has been made, warn if not, then open an edit screen for the selected row)

you can check selected row by using


you can deselect a row by using

'This should work 

'Try this if the first one doesn't work 
Datagridview.CurrentRow.Selected = false

Best thing to do is set the focus on another control in page load event.

'Unfortunately these methods do not deselect the Row Header
    Datagridview.CurrentRow.Selected = false

    'And nor does moving the focus to another control
    'Any other ideas?
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.