当用户单击表单2上的按钮时,我想刷新主窗口1上的几个文本框。基本上,文本框将存储实时库存。
这是我到目前为止所尝试的内容:
form1.subThatRefreshesTextboxes
谢谢
答案 0 :(得分:0)
有一种干净的方法可以做到这一点,
首先,在表单1中,创建一个Public Sub
,它将刷新()您的TextBox。然后,从表单2,您调用Form 1的Sub。
Public Class Form1
'Some code here
Public Sub RefreshMyTextBox()
If Me.InvokeRequired() Then
Me.Invoke(Sub() RefreshMyTextBox())
Else
'Code to refresh your textbox here
End If
End Sub
'Some code there
End Class
表格2
Public Class Form2
'Some code here
private _form1 As Form1 'You need a reference to Form1
Private Sub Button_Clicked(sender As Object, e As EventArgs) Handles Button.Click
'Whenever you need it, call the Form1.RefreshMyTextBox
Me._form1.RefreshMyTextBox()
End Sub
'Some code there
End Class