【问题标题】:Showing Textbox ToolTip显示文本框工具提示
【发布时间】:2012-07-17 14:28:50
【问题描述】:

我正在尝试使用 vb.net 中的工具提示。我想要做的是我在文本框控件中写入的文本在工具提示中显示它。我可以在工具提示中显示文本,但我的问题是当我编辑输入文本时,它会在弹出工具提示中显示新旧文本。这是我到目前为止所做的。

Public Class Form1
  Dim s As String = ""

  Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
    s = TextBox1.Text
    Dim tooltip1 As System.Windows.Forms.ToolTip = New System.Windows.Forms.ToolTip()

    tooltip1.SetToolTip(Button1, s)
  End Sub
End Class

谢谢。

【问题讨论】:

    标签: vb.net winforms tooltip


    【解决方案1】:

    很难弄清楚为什么这很有用,但请尝试使用文本框的TextChanged 事件来更新工具提示:

    Private _ToolTip As New ToolTip()
    
    Private Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As EventArgs) _
                                     Handles TextBox1.TextChanged
      _ToolTip.Show(TextBox1.Text, TextBox1)
    End Sub
    

    【讨论】:

      猜你喜欢
      • 2011-07-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-14
      • 2014-02-07
      • 2018-10-24
      • 1970-01-01
      相关资源
      最近更新 更多