| re: How to trap if a cancel has occurred on cell validation?
Hi,
"Bob" <bdufour@sgiims.com> wrote in message
news:%23SSnXCyEGHA.1312@TK2MSFTNGP09.phx.gbl...[color=blue]
> In a winform with a datagridview using cellvalidating event but also have
> a save button that is located on a tablebindignnavigator.
> The behaviour I observe is that if the cellvalidating issues a cancel =
> true after the save button has been clicked, the update statements in the
> click event of the save button still occur but nothing gets saved,[/color]
The current (invalid) record may not be saved, but if the user had a chance
to change other records before that then those records will still be saved.
[color=blue]
> which is OK. Except that I pop a message box in the click event after the
> update statements have been successfully executed (they're in a try catch
> construct) to say Save completed.
>
> This gives me the situation where Cellvalidating issues a false cxancels
> the update, the save does not occur, but my user gets message Save
> succeeded!
> This is the code in the cellvalidating event.
>[/color]
[code snipped]
[color=blue]
>
> This is the code that does the updates
>
> Private Sub SaveCompanyInfo()
>
> Try
>
> Me.Validate()[/color]
Because the BindingNavigator doesn't cause validation, it is postponed until
here, Validate() performs the last validation and returns the result.
Dim validateOK As Boolean = Me.Validate()
HTH,
Greetings
[color=blue]
>
> Me.TblCompanyBindingSource.EndEdit()
>
> Me.TblCompanyTableAdapter.Update(Me.DsCompanyInfo. tblCompany)
>
> Me.TblCompanyAddressesBindingSource.EndEdit()
>
> Me.TblCompanyAddressesTableAdapter.Update(Me.DsCom panyInfo.tblCompanyAddresses)
>
> Me.TblCompanyPhonesBindingSource.EndEdit()
>
> Me.TblCompanyPhonesTableAdapter.Update(Me.DsCompan yInfo.tblCompanyPhones)
>
> If
> System.Globalization.CultureInfo.CurrentUICulture. TwoLetterISOLanguageName
> = "fr" Then
>
> MsgBox("Sauvegarde réussie!")
>
> Else
>
> MsgBox("Save completed!")
>
> End If
>
> Catch ex As Exception
>
> MsgBox(ex.Message)
>
> End Try
>
> End Sub
>
> Bfore I execute the msgbox, I should know if a cancel has been issued by
> any cellvalidating events in any of the datagridviews on te form- there
> are two others.
>
> How do i determine that. Ther does not seem to be an event in any of the
> datasets or the datagridviews that indicates that a cancel has occured.
>
> Any help would be greatly appreciated.
>
> Bob
>
>
>
>
>
>[/color] |