0

我的问题:

我在文本框上使用气球提示来指示非数字输入(实时)。一旦输入了第二个非数字字符,球囊尖端位置和杆方向就会改变(反转并且不希望出现

重现:

  1. 在 Visual Studio 中,在设计模式下,将文本框和工具提示拖到新窗体上。
  2. 按原样使用以下内容:

代码:

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
4

1 回答 1

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
于 2014-10-23T13:09:20.457 回答