我正在使用一个带有2个窗口表单的项目,一个带有超级网格的主页表单,显示一些数据,另一个用于_dd数据。 我想在添加数据表单关闭时刷新超网格,但目前无法这样做。
我需要在form_closing
子例程中添加数据Public Shared Sub
以允许我使用加载数据的主窗体上的子例程获取ShowDialog.OK
值,因此它知道是否刷新它。但是,因为它是共享子,我无法使用Me.Dispose
。我该如何解决这个问题?
Private Sub fHome_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' This is where the UltraGrid gets it's data from
If fAdd.ShowDialog() = DialogResult.OK Then
uwgDisplay.DataSource = Nothing
displayData()
' addData form is open, then get the data from the database (dont refresh it)
Else
displayData()
' if add data form is closed, then refresh the data
End If
Me.Location = New Point(0, 0)
End Sub
这是添加表单上的表格结束子
Public Shared Sub Form_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If Globals.savedValue = False Then
Dim closeBox As MsgBoxResult
closeBox = MsgBox("Exit without saving?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Confirm")
If closeBox = MsgBoxResult.Yes Then
Me.Dispose()
ElseIf closeBox = MsgBoxResult.No Then
e.Cancel = True
Exit Sub
End If
Else
Me.Dispose()
End If
End Sub
我告诉<{1}}两行{/ p>
Me仅在实例方法中有效
答案 0 :(得分:0)
您的陈述
&#34;我需要从form_closing子程序a中添加数据 Public Shared Sub允许我获取ShowDialog.OK&#34;
不正确。您不需要共享FormClosing方法以获取DialogResult
Private _myform As frmFoo
Private Sub Button19_Click(sender As Object, e As EventArgs) Handles Button19.Click
If _myform Is Nothing Then _myForm = New frmFoo
If _myform.ShowDialog = DialogResult.OK Then
'do something
End If
End Sub