TextBox string as tooltip on hover

心已入冬 提交于 2021-01-28 18:05:05

问题


I'm building an application and I have a TextBox control that is filled with a value. On some occasions the control is too small and I don't have the space to expand it.

How do you show the TextBox content on hover when the control is too small?


回答1:


Add a tooltip to the form and the following code

 Private Sub TextBox1_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.MouseHover
    ToolTip1.SetToolTip(TextBox1, TextBox1.Text)
End Sub



回答2:


This has the same answer as this question: Showing Textbox 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


来源:https://stackoverflow.com/questions/38244139/textbox-string-as-tooltip-on-hover

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