Click here to Skip to main content
16,012,107 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi All,

I have a tab which has a Datagridview where user is allowed to edit a particular column and a button ' Save'which they shud hit inorder to Save. If the user edits the column and forgets to hit Save i need to display warning that the Data is not saved. How do i do this ?

I tried
Private Sub Gridview1_CurrentCellDirtyStateChanged(sender As Object, e As EventArgs) Handles Gridview1.CurrentCellDirtyStateChanged
       If Gridview1.IsCurrentCellDirty Then
           Gridview1.CommitEdit(DataGridViewDataErrorContexts.Commit)
       End If
   End Sub

   Private Sub GridView1_CellValueChanged(sender As Object, e As DataGridViewCellEventArgs) Handles Gridview1.CellValueChanged
       If (e.ColumnIndex = 3) Then
           If (btnAdd.Enabled = True And bBtnClicked = False) Then
               MsgBox("Data  not saved.")

           End If
       End If
   End Sub


This basically throws error on every cell change event. I don't want this. I want to display only when the user leaves the tab . Please help. Thanks.
Posted
Updated 23-Sep-13 5:08am
v5

1 solution

Okay, so what's the problem? Don't show this message box. Instead, just have a Boolean flag modified and set it to true instead, silently. Later on, when the user changes the tab, check up this flag and process accordingly.

—SA
 
Share this answer
 
Comments
vidkaat 23-Sep-13 11:58am    
I tried to do as wat you said. But I am also validating cell value using CellValidating event. If i use the above validation my cell validating does not seem to work .Help me with it.

My cellvalidating event has the validation to check if the value entered by the user is greater than the existing value. If not i popup a message. I need to validate this and also i need to check if the user has saved his changes.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900