[英]how to bring the form in front after closing another form in vb.net
i have my main form and it has a button that will show the second form and it enabled = false the first form. 我有我的主窗体,它有一个按钮,它将显示第二个窗体,并且启用= 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
when you click the button on the second form it will go back to the first form and it will enabled = true. 当您单击第二个表单上的按钮时,它将返回第一个表单,并且将启用= 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
what my problem is that when i click "back" button the second form is gone but the first form is sent at the back of the current window, you still need to minimize that particular window to see the form 1 again. 我的问题是,当我单击“后退”按钮时,第二个表单不见了,但是第一个表单是在当前窗口的后面发送的,您仍然需要最小化该特定窗口才能再次看到表单1。
Have you tried making the second form a "modal" form, with ShowDialog
? 您是否尝试过使用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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.