共享子程序&价值解析

时间:2016-07-14 08:54:04

标签: vb.net infragistics ultragrid ultrawingrid

我正在使用一个带有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仅在实例方法中有效

1 个答案:

答案 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
相关问题