DataGridView SelectionChanged event problem

B

Brano

Hi all,

I have two DataGridViews one has some data in it the other one's data
changes according to the selected row in the first dgw. User is
allowed to add / change data in the second dgw. I want to implement
functionality to see if there was a change on the second dgw and if so
prompt for save. I have done this using the following code:

Private Sub dgSecond_SelectionChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles dgSecond.SelectionChanged

If dsSecond.HasChanges Then
Dim res As MsgBoxResult
res = MsgBox("Do you want to save the changes you made?",
MsgBoxStyle.YesNoCancel)
If res = MsgBoxResult.Cancel Then Exit Sub
If res = MsgBoxResult.Yes Then btnSave_Click(Me, e)
'If res = MsgBoxResult.No Then '# do nothing

End If

'# populate the disciplines
populateDisciplineSettings()

End Sub

The problem is that once the code hits SelectionChanged the row in the
First grid is already selected and I don't know how to revert back to
the previous row if user clicks CANCEL

any help much appreciated. thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top