我有一个topicbar共有窗口,里面有多个主窗口。当从主窗口A切换到主窗口B时,如果主窗口A有未保存的数据需要提醒用户要保存后才能离开,应该写在哪个事件里面。我现在写在主窗口A的BeforeClose里面不起作用,代码如下:
If Tables("销售订单").Current.DataRow.RowState = DataRowState.Added AndAlso Tables("销售明细表").Current Is Nothing Then
Tables("销售订单").Current.Delete
DataTables("销售订单").save
ElseIf Tables("销售订单").Current.DataRow.RowState = DataRowState.Added AndAlso Tables("销售明细表").Current IsNot Nothing Then
MessageBox.show("当前订单尚未保存,不能关闭!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
e.Cancel = True
End If
但在窗口设计器时预览,点右上角的关闭按钮时有起作用的。