0

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

Me.DataGridView.ClearSelection()

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)

3
Contributors
3
Replies
5
Views
5 Years
Discussion Span
Last Post by pROKO
0

you can check selected row by using

DataGridView.CurrentRow.Index

you can deselect a row by using

'This should work 
Datagridview.ClearSelection()

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

Edited by bluehangook629: n/a

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

    'And nor does moving the focus to another control
    'Any other ideas?
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.