我的表单中有一个文本框。单击托盘图标时,会显示表单并在表单加载时编写代码以专注于文本框。但它没有指向文本框。让我有 2 个表单 formB 和 formC 我从 formB 调用 formC,这样我就不会得到焦点。如何将重点放在第二种形式上?我找到了解决这个问题的方法。我们必须覆盖 show 方法。比方说formA和formB。然后FormB现在成为焦点。
Private Sub FormB_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Timer1.Enabled = True
Me.Timer1.Interval = 2000
End Sub`
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Timer1.Enabled = False
Dim frmquickListPHD1 As New FormC()
frmquickListPHD1.Show(CallingForm, CallingControl, Me)
End Sub
Overloads Sub Show(ByVal f1 As Form, ByVal c As Control, ByVal f2 As Form)
callingform = f1
MenuForm = f2
callingcontrol = c
Show()
End Sub
Private Sub FormC_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.TextBox1.Focus()
End Sub`