我有2个表单,Form1是父表单,Form2是子表单。他们两个都设置为同时显示..... Form1的中间容器设置为true并有一个按钮,Form2有一个文本框...我希望如果我在Form1中按按钮将出现在Form2的文本框中
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
IsMdiContainer = True
Dim inv As New Form2
inv.MdiParent = Me
inv.Show()
inv.Location = New Point(15, 15)
End Sub
我尝试单击按钮,但没有任何反应,我也尝试了另一种方法...在Form2中放置一个按钮,在Form1中放置一个文本框,它可以正常工作...
您将不得不将inv
变量移出form_load范围
Public Class Form1
Private inv As New Form2 'here
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
IsMdiContainer = True
inv.MdiParent = Me
inv.Show()
inv.Location = New Point(15, 15)
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
inv.TextBox1.Text = "Hello World"
End Sub
End Class
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句