2

I am trying to work in the tooltip in vb.net. What I am trying to do is whatever I write the text in the textbox control show it in the tooltip. I am able to show text in tooltip but my question is when I edit input text it will show old and new text in the popup tooltip. Here is what I have done so far.

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

Thank you.

LarsTech
  • 80,625
  • 14
  • 153
  • 225
bokshi
  • 43
  • 1
  • 2
  • 5

1 Answers1

2

It's hard to figure out why this is useful, but try using the TextChanged event of the textbox to update the tooltip:

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
LarsTech
  • 80,625
  • 14
  • 153
  • 225