vb.net中,在程序运行,用户未操作时,使文本框textbox1获取焦点的代码是什么
2015-04-06
展开全部
Public Class Form3
按下,显示控件,并获得焦点.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Visible = True
TextBox1.Focus()
End Sub
判断是否获得焦点.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If TextBox1.Focused = True Then
MessageBox.Show("已经获得焦点了.")
Else
MessageBox.Show("已经失去焦点了.")
End If
End Sub
失去焦点后自动陷藏.
Private Sub TextBox1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.LostFocus
TextBox1.Visible = False
End Sub
End Class
按下,显示控件,并获得焦点.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Visible = True
TextBox1.Focus()
End Sub
判断是否获得焦点.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If TextBox1.Focused = True Then
MessageBox.Show("已经获得焦点了.")
Else
MessageBox.Show("已经失去焦点了.")
End If
End Sub
失去焦点后自动陷藏.
Private Sub TextBox1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.LostFocus
TextBox1.Visible = False
End Sub
End Class
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询