Adding Custom Tooltips for Visual Basic .NET

Click Star to Rate Post
1 Star2 Stars3 Stars4 Stars5 Stars (4 votes, average: 4.00 out of 5)
 

This is a very old article but decided to repost it for beginners of .NET coming from VB 6.0.


In Visual Basic 6.0 we had a simple Tooltip property for the controls. All you needed to do was supply the text you wanted to be shown. While Visual Basic.NET did remove that property, you didn’t really have control over the toolTips in general with VB 6.0. For instance, you couldn’t set the delay time, duration, balloon style, and so on.

Now with VB.NET there is a Tooltip component that is more advanced than the VB 6.0 feature. It is very simple to implement and you have more control on how your tooltips will react and display. For example, you can now set the length of time the pointer must remain stationary within the area or region before the text will appear.

To get started simply open a project. In your Toolbox look for a ToolTip component. If you do not see one right click inside your toolbox and select “Customize Toolbox”. Click the “.NET Frameworks Components” tab, scroll down till you find “ToolTip”, then check the box and press OK. You should now see a ToolTip component available. Double click the ToolTip to add it to your project. I just renamed mine toolTip. If you look at the properties available for the ToolTip you will see: Automatic Delay, Initial Delay, and so on. I will not go over any of these settings since they are pretty much self-explanatory. Go ahead and add a button to the form. I named mine btn. Then in the Btn_MouseHover event put:

toolTip.SetToolTip(btn, "Hello, This is just a simple test....")

Start your project and place your mouse pointer within the button region and let it sit idle for a few moments. You should then see the ToolTip balloon popup with the text you specified.

You can also go to the ‘btn’ Button’s property window. You will see a property named: “tooltip on ToolTip”. You can put the text you want displayed for that control and and the text will be displayed and controlled by the properties specified in your ToolTip component without you needing to execute any toolTip code yourself.

So in the end you have more control with your tooltips in .NET. You can make the tips look more balloon like, display longer, delay longer, and so on. Have fun!

                Jason

6 thoughts on “Adding Custom Tooltips for Visual Basic .NET

  1. jsmith

    It’s not a balloon tip…

    Spent 2 hours googling BALLOON TIPS on Google and ended up here. Idiotic…

    Reply
  2. michaelb958

    In reply to Sam: In fact, the NotifyIcon component (which does stuff with your system tray icon) has its own BalloonTipIcon, BalloonTipTitle and BalloonTipText properties.

    Reply

Leave a Reply

Your email address will not be published.