在代码中 txtname.text="" 时,程序就会执行TextChanged事件,如何让它不执行,我们可以定义一个判断条件
Dim ifCF As Boolean = True '是否执行textchanged事件
Private Sub txtname_TextChanged(sender As Object, e As EventArgs) Handles txtname.TextChanged, txttuhao.TextChanged, txtmodel.TextChanged, txtcz.TextChanged
If ifCF = True ThenGetTextValue()
End If
End Sub
在后面的代码我们就用ifCF 来判断
ifCF = False
txtname.text=""
ifCF = True
本文介绍了一种在Visual Basic.NET中通过设置布尔变量ifCF来控制TextChanged事件触发的方法,以避免因特定操作(如清空文本框)而引发不必要的事件处理。
293

被折叠的 条评论
为什么被折叠?



