所以这是交易。
我正在使用VB.net 2012.
我的textBox包含TextChanged
个事件。它具有一定的价值。
但在使用此事件之前,我必须加载一些函数。
因此,当我加载表单时,我得到错误,因为代码读取此事件并且未加载函数。
我想要做的是在我第一次启动表单时忽略这些事件:)
提前致谢
答案 0 :(得分:2)
设置标记并在TextChanged()事件中进行检查。在Shown()事件中切换标志:
Public Class Form1
Private Loading As Boolean = True
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
TextBox1.Text = "Hello from the Load() event!"
End Sub
Private Sub Form1_Shown(sender As Object, e As System.EventArgs) Handles Me.Shown
Loading = False
End Sub
Private Sub TextBox1_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox1.TextChanged
If Not Loading Then
Debug.Print("TextChanged")
' ... your code in here ...
End If
End Sub
End Class