Vb.net vb。net等待第二个表单关闭,然后继续
在vb.net中是否有方法暂停函数\事件并等待另一个窗体关闭以继续 例如:Vb.net vb。net等待第二个表单关闭,然后继续,vb.net,wait,formclosing,Vb.net,Wait,Formclosing,在vb.net中是否有方法暂停函数\事件并等待另一个窗体关闭以继续 例如: Private Sub B1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1.Click label1.text="Hello testing.." '1st function form2.show() '2nd function 'MAKE FORM WAIT FOR FORM 2 TO CLOSE.
Private Sub B1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1.Click
label1.text="Hello testing.." '1st function
form2.show() '2nd function
'MAKE FORM WAIT FOR FORM 2 TO CLOSE...
'THEN CONTINUE WITH THE NEXT FUNCTION
msgbox("Some function that was waiting in the event") '3rd function
end sub
我能找到的最接近我想要的东西是一个输入框,但输入框在我想要的东西上是有限的,尽管它会等待,因为我希望Form2能够正常工作
另一个建议是循环,直到form2关闭,但是这是一个黑客和非专业的解决方案(我的建议)只需更改:
form2.Show()
致:
从以下文件中:
可以使用此方法在对话框中显示模式对话框
应用调用此方法时,它后面的代码不会被调用
直到对话框关闭后执行
请注意,在上面的简化示例中,我们没有捕获ShowDialog()
的返回值
我们可以使用返回值来确定是否应执行后续代码:
If form2.ShowDialog() = DialogResult.OK Then
' ... do something in here ...
End If
使用
ShowDialog
将表单显示为模式对话框
您可以使用DialogResult
Public Sub ShowMyDialogBox()
Dim testDialog As New Form2()
' Show testDialog as a modal dialog and determine if DialogResult = OK.
If testDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK Then
' Read the contents of testDialog's TextBox.
txtResult.Text = testDialog.TextBox1.Text
Else
txtResult.Text = "Cancelled"
End If
testDialog.Dispose()
End Sub 'ShowMyDialogBox
public cerrar
Private Sub form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
form2.show()
Do
cerrar = form2.Visible
Loop Until cerrar = False
continue codigo
End Sub
要将DialogResult分配给按钮,只需使用按钮属性:
按钮。DialogResult
事实上,InputBox是包装在函数中的模式对话框。如果你想要更多的功能,你可以很简单地制作自己的。请你在回答中添加一些解释。
Public Sub ShowMyDialogBox()
Dim testDialog As New Form2()
' Show testDialog as a modal dialog and determine if DialogResult = OK.
If testDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK Then
' Read the contents of testDialog's TextBox.
txtResult.Text = testDialog.TextBox1.Text
Else
txtResult.Text = "Cancelled"
End If
testDialog.Dispose()
End Sub 'ShowMyDialogBox
public cerrar
Private Sub form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
form2.show()
Do
cerrar = form2.Visible
Loop Until cerrar = False
continue codigo
End Sub