Solved

Datagridview Data Change Event

Posted on 2011-03-10
3
1,370 Views
Last Modified: 2012-05-11
I have a datagridview linked to an Access database, and I want to prompt the user if they want to save the changes they make when they leave a row.  I have it working fine, only I wish to prompt them only if there is a change to the data in the row they leave.  Right now if the user is clicking the down arrow through the rows they are prompted each time they leave the row...not very good programming indeed!

Any help would be much appreciated.


Private Sub DataGridView1_RowLeave(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.RowLeave
Dim Response
Response = MsgBox("Do you want to save changes?", MsgBoxStyle.YesNo, "Warning!")
If Response = vbYes Then
  Call SaveData()
End If
End Sub

Open in new window

0
Comment
Question by:bhlabelle
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
nepaluz earned 500 total points
ID: 35094781
If the grid is bound to the datasource, I am not sure if the data is not aved automatically, however, you could create a global variable to hold the value of the cell being EDITED by handling the CellBeginEdit and comparing the value in CellEndEdit. If the values are different, then call your prompt else be quiet!

0
 

Author Comment

by:bhlabelle
ID: 35094960
I like the idea.  I'll probably work on it later today and respond accordingly.

And the data is not saved automatically, at least how I have it set up.  I had to write an update command in the datasourceeditor.
0
 

Author Closing Comment

by:bhlabelle
ID: 35097069
Thank, very easy to impliment.  I just added a string to set the value of the cell before the edit, added another string to set the value of the cell after the edit, if they are not the same then I prompt if the user wants to save the changes.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now