我有我的主表单,它有一个显示第二个表单的按钮,它启用= false第一个表单。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form2.Show()
Me.Enabled = False
End Sub
当您单击第二个表单上的按钮时,它将返回到第一个表单,它将启用= true。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Hide()
Form1.Enabled = True
End Sub
我的问题是,当我单击“后退”按钮时,第二个表单消失但第一个表单在当前窗口的后面发送,您仍然需要最小化该特定窗口以再次查看表单1。
答案 0 :(得分:1)
您是否尝试使用ShowDialog
?
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If Form2.ShowDialog() = Windows.Forms.DialogResult.OK Then
MsgBox("OK!")
Else
MsgBox("Cancelled :-(")
End If
End Sub
End Class
Public Class Form2
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.DialogResult = Windows.Forms.DialogResult.OK
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.DialogResult = Windows.Forms.DialogResult.Cancel
End Sub
End Class