DataGridView SelectionChanged event problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brano

    #1

    DataGridView SelectionChanged event problem

    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_Select ionChanged(ByVa l sender As Object, ByVal e
    As System.EventArg s) Handles dgSecond.Select ionChanged

    If dsSecond.HasCha nges Then
    Dim res As MsgBoxResult
    res = MsgBox("Do you want to save the changes you made?",
    MsgBoxStyle.Yes NoCancel)
    If res = MsgBoxResult.Ca ncel Then Exit Sub
    If res = MsgBoxResult.Ye s Then btnSave_Click(M e, e)
    'If res = MsgBoxResult.No Then '# do nothing

    End If

    '# populate the disciplines
    populateDiscipl ineSettings()

    End Sub

    The problem is that once the code hits SelectionChange d 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

Working...