[RESOLVED] Cancel selection changed in datagridview
Hi all,
Ive got a datagridview, which the user can put in to 'edit' mode by double clicking. If they then make changes but click to another row, I want to msg asking if they are sure they want to discard then changes. If they say No I want to stop the selection change from being made.
Code:
Private Sub DataGridView1_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGridView1.SelectionChanged
If edit = True Then
Dim result As String = MsgBox("Are you sure you want to discard your changes?", MsgBoxStyle.YesNo)
If result = vbYes Then
clearedit()
Else
'Here is where I need to cancel the selection change
End If
Else
clearedit()
End If
Re: Cancel selection changed in datagridview
I dont understand.
You wanna your datagridview pass to read only again??
Re: Cancel selection changed in datagridview
No, maybe I confused you by saying edit mode... ignore that!
How do I go back to the previous selected row on the selection changed event.
Re: Cancel selection changed in datagridview
Re: Cancel selection changed in datagridview
Store the row number then restore it:
Code:
grdComplete.Rows(intRow).Selected = True
grdComplete = DataGridView
intRow = index of the row that was being edited.
Re: Cancel selection changed in datagridview
Re: Cancel selection changed in datagridview
Cant give you rep again MarMan
Re: [RESOLVED] Cancel selection changed in datagridview
That's OK. The appreciation is appreciated.
Re: [RESOLVED] Cancel selection changed in datagridview
Just took a different way of thinking about it. Silly me! Thanks for the help