Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Achieve tooltip like this in VB.net?

I found this tooltip that pops up in MS Word 2010 when someone enters a copy count above 32767, I would like to know how (and if) it is possible to implement a tooltip such as this within a VB.net windows form application.

tooltip screenshot MSWord 2010

like image 348
rabbitt Avatar asked May 01 '12 01:05

rabbitt


2 Answers

The built-in ToolTip component creates a tooltip that looks pretty close. Set its IsBalloon property to True. Getting it exactly like Word is not practical, the component doesn't provide any way to override the TOOLINFO.uFlags value so you could specify TTF_CENTERTIP..

enter image description here

like image 82
Hans Passant Avatar answered Oct 27 '22 17:10

Hans Passant


I tried the Balloon, but it was unpredictable as to which way it was orientated. However, the following code might get you started... I assume it's not bullet proof so you might need to add some more code.

I used a textbox and a tooltip from the tools menu:

Private Sub TextBox1_TextChanged(sender As System.Object, e As System.EventArgs) Handles      TextBox1.TextChanged

If Val(TextBox1.Text) > 100 Then
        ToolTip1.Active = True
        ToolTip1.Show("Value is to Large", sender, New Drawing.Point(0, sender.Height - 50))
    Else
        ToolTip1.Active = False
    End If

End Sub

I really like this idea... Thanks!

like image 43
Steven0100 Avatar answered Oct 27 '22 15:10

Steven0100