Hi,
i have a problem canceling the ActiveWindowChanging events.
When i enter in this event i check if the last ActiveWindow is updated. If not i ask user to chose to save, or not, data to db.
If user chose to save, i update data in db, and proced changing the Active Window, as user wants. But when i save data, if i get an exception, i send a msgbox to user, and i want to "reactivate" the last ActiveWindow. In this way, the user can edit data to complete it or discard it.
How can i cancel the window changing?
I try with e.cancel = true, but the program loops :(
I'm sorry if code is not clear; this is only for understand if i wrong something in it, with the e.cancel = true.
Thanks
i have a problem canceling the ActiveWindowChanging events.
When i enter in this event i check if the last ActiveWindow is updated. If not i ask user to chose to save, or not, data to db.
If user chose to save, i update data in db, and proced changing the Active Window, as user wants. But when i save data, if i get an exception, i send a msgbox to user, and i want to "reactivate" the last ActiveWindow. In this way, the user can edit data to complete it or discard it.
How can i cancel the window changing?
I try with e.cancel = true, but the program loops :(
| Private Sub RadDock1_ActiveWindowChanging(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.Docking.DockWindowCancelEventArgs) Handles RadDock1.ActiveWindowChanging |
| ' Salvo il Layout del tab che sto chiudendo |
| For Each c As Control In RadDock1.ActiveWindow.Controls |
| Select Case c.GetType.ToString |
| Case "Commesse" |
| Dim mycontrol As AnagraficaCommesse = TryCast(c, AnagraficaCommesse) |
| mycontrol.SaveGridLayout() |
| Case "Articoli" |
| Dim mycontrol As Commesse_Articoli = TryCast(c, Commesse_Articoli) |
| mycontrol.SaveGridLayout() |
| If mycontrol.RadGridView1.IsInEditMode() Then |
| If MsgBox("Un record non è stato salvato! Si desidera salvarlo ora?", MsgBoxStyle.YesNo, "Salvare i dati?") = MsgBoxResult.Yes Then |
| Try |
| mycontrol.RadGridView1.EndEdit() |
| mycontrol.UpdateDataSource() |
| Catch ex As Exception |
| MsgBox("Si è verificato un problema durante il salvataggio dei dati. Controllare che i dati inseriti siano corretti", MsgBoxStyle.Critical, "Errore") |
| e.Cancel = True |
| End Try |
| Else |
| mycontrol.RadGridView1.EndEdit() |
| End If |
| End If |
| End Select |
| Next |
| End Sub |
I'm sorry if code is not clear; this is only for understand if i wrong something in it, with the e.cancel = true.
Thanks