如何检测在sperate表单上按下按钮的时间 [英] How do I detect when a button is pressed on a sperate form
问题描述
在我的第一个表格中,我有四个按钮。程序启动时,其中2个被禁用。在form2中,当我按下Form2中的按钮时,我希望启用2个禁用按钮。
我尝试过:
我尝试过使用
如果Form2.FinishButton_Click = True那么
PrintButton.Enabled = True
SendButton.Enabled = True
结束如果
In my first form, I have four buttons. 2 of them are disabled when the program starts. In form2 I want the 2 disabled buttons to be enabled when I press a button in Form2.
What I have tried:
I have tried using
If Form2.FinishButton_Click = True Then
PrintButton.Enabled = True
SendButton.Enabled = True
End If
推荐答案
在带有FinishButton的表单上:
On the form with FinishButton:
Private Sub FinishButton_Click(sender As Object, e As EventArgs) Handles FinishButton.Click
Form1.PrintButton.Enabled = True
Form1.SendButton.Enabled = True
End Sub
将Form1替换为PrintButton&的形式名称。 SendButton
Replace "Form1" with the name of the form of PrintButton & SendButton
'在第一种形式中,您必须在Form2.tag属性中发送form1,如下所示
'In first form you have to send the form1 in Form2.tag property like below
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim frm2 As New Form2
frm2.Tag = Me
frm2.Show()
End Sub
'以下代码在Form2中
'Below codes are in Form2
Private frmlog As Form
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not IsNothing(Me.Tag) Then
Frm1 = DirectCast(Me.Tag, Form)
Frm1.Hide()
End If
End Sub
'以下代码在Form2中
'Below codes are in Form2
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Form1.button1.Enabled = True
Form1.button2.Enabled = True
End Sub
'如果你有解决方案,不要忘记接受答案
'don't forget to accept answer if you got solution
你的代码是无意义的,因为它显示...
你需要做的是:
在Form2上捕获FinishButton.Click-Event(使用方法)。
在这个方法中你可以设置'Form1 .PrintButton.Enabled = True'以及'Form1.SendButton.Enabled = True'
Your Code is nonsense as it's shown ...
What you have to do is :
Catch the FinishButton.Click-Event on Form2 (with a method).
Inside this method you can set the 'Form1.PrintButton.Enabled = True' and also the 'Form1.SendButton.Enabled = True'
这篇关于如何检测在sperate表单上按下按钮的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!