我在文本框中使用气球提示来指示非数字输入(实时)。一旦输入第二个非数字字符,气球尖端位置和杆方向就会改变(反转并且不合需要地
代码:
Public Class Form1
Private Sub Textbox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
If (Not IsNumeric(TextBox1.Text) And TextBox1.Text.Length > 0) Then
ToolTip1.ToolTipTitle = "Input must be numeric!"
ToolTip1.Active = True
ToolTip1.IsBalloon = True
ToolTip1.Show(vbNewLine, TextBox1, 45, -40)
Else
ToolTip1.Active = False
ToolTip1.Hide(TextBox1)
End If
End Sub
End Class
答案 0 :(得分:1)
您可以在显示之前检查tooltip
是否可见:
Private Sub TextBox1_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox1.TextChanged
If (Not IsNumeric(TextBox1.Text) And TextBox1.Text.Length > 0) Then
If ToolTip1.GetToolTip(TextBox1) = "" Then
ToolTip1.ToolTipTitle = "Input must be numeric!"
ToolTip1.Active = True
ToolTip1.IsBalloon = True
ToolTip1.Show(vbNewLine, TextBox1, 45, -40)
End If
Else
ToolTip1.Active = False
ToolTip1.Hide(TextBox1)
End If
End Sub