我正尝试在vb.net中的工具提示中工作。我试图做的是,无论我在textbox控件中编写文本,都会在工具提示中显示它。我可以在工具提示中显示文本,但我的问题是,当我编辑输入文本时,它会在弹出的工具提示中显示旧文本和新文本。以下是我到目前为止所做的工作。
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谢谢。
发布于 2012-07-18 22:22:51
很难弄清楚这为什么有用,但请尝试使用textbox的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 Subhttps://stackoverflow.com/questions/11543318
复制相似问题