写WinForm的Closing事件,判断: if (ds.HasChanges) messagebox.show("有数据需要更新!");
在窗口的Closing事件中加入对你的数据表检测代码,示例如下: Dim tb As DataTable '你的数据表 Private Sub FrmSelect_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing If Not tb.GetChanges Is Nothing AndAlso tb.GetChanges.Rows.Count > 0 Then If MessageBox.Show("要保存数据吗?") = DialogResult.Yes Then '执行你的保存代码 End If End If End Sub
Dim tb As DataTable '你的数据表
Private Sub FrmSelect_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
If Not tb.GetChanges Is Nothing AndAlso tb.GetChanges.Rows.Count > 0 Then
If MessageBox.Show("要保存数据吗?") = DialogResult.Yes Then
'执行你的保存代码
End If
End If
End Sub