Solved

Datagridview Data Change Event

Posted on 2011-03-10
3
1,380 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

707 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