Visual Basic无法更改表单文本

时间:2013-12-15 17:44:05

标签: .net windows visual-studio-2010

Public Class Form1

    Dim pro As Process
    Public Event Exited As EventHandler

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        pro = New Process
        pro.StartInfo = New ProcessStartInfo("notepad")
        pro.Start()
        pro.EnableRaisingEvents = True
        AddHandler pro.Exited, AddressOf process_Exited
    End Sub

End Class


Module something
    Public Sub process_Exited(ByVal sender As Object, ByVal e As System.EventArgs)
        Form1.Text = "ok"

        MsgBox("Was called")
    End Sub
End Module

Form1的文本没有改变,即使我可以告诉自从消息框显示以来调用了该函数。

我在Form1.Text =“ok”之后尝试过Form1.Refresh(),但它仍然是“Form1”。

为什么会这样,我该如何解决?

0 个答案:

没有答案