Why are balloon tip position and stem orientation buggy?

試著忘記壹切 提交于 2019-12-12 02:00:51

问题


My problem:

I'm using a balloon tip on a text box to indicate non-numeric entry (real-time). Once a second non-numeric character is inputted, the balloon tip position and stem orientation changes (inverts and undesirably

To reproduce:

  1. In Visual Studio, in design mode, drag a text box and tooltip onto a fresh form.
  2. Use the following as is:

Code:

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

回答1:


You can check if tooltip is visible before showing it:

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


来源:https://stackoverflow.com/questions/26528559/why-are-balloon-tip-position-and-stem-orientation-buggy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!