ruedi
ruedi

Reputation: 5545

message when leaving a datagridview

I have a datagridview with a menustrip. I want to give the user a message that he has to save when he leaves the datagridview and made any changes in there. What i tried:

Private Sub DGV_validated(sender As Object, e As EventArgs) Handles DGV.validated
If DataSet1.table.GetChanges IsNot Nothing Then
MsgBox("You made changes please press the save button!")
End If
End Sub

I tried that with the leave, validated and lostfocus event but the msgbox pops up not until i am on another form after pressing something in the menustrip.

Upvotes: 1

Views: 508

Answers (1)

Dave H
Dave H

Reputation: 653

I just made a forms project with a DataGridView on the form and put this in the code behind and it worked without issue:

Private Sub DataGridView1_MouseLeave(sender As Object, e As System.EventArgs) Handles DataGridView1.MouseLeave
    MsgBox("hi")
End Sub

Basically, after the cursor leaves the DataGridView, the MsgBox will pop up. Is that what you were looking for? This was done in Visual Studio 2010.

Upvotes: 0

Related Questions