By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,261 Members | 1,688 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,261 IT Pros & Developers. It's quick & easy.

DataGridView SelectionChanged event problem

P: n/a
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

Jul 3 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.