Creating multiline tooltips

In VB6 there was no easy way to create multiline tooltips for form controls, you necessarily had to resort to API tricks. And it was probably just not worth the effort. The good news is that doing this is straightforward in VB.NET! First add a Tooltip Provider control on the form to add the Tooltip On TooltipProviderCtl property to all the controls on the form, and set your tooltip as a single line long text. Finally, go to the code view, within the InitializeComponent method locate the line that set the tooltip, and split the tooltip text with new-line characters, as you would do with any other string. Here’s an example:

Me.ToolTipProviderCtl.SetToolTip(Me.Button1, "this is" & environment.NewLine & _    "a multiline" & environment.NewLine & "tooltip!")

Instead of modifying the code directly in InitializeComponent, you can programmatically set multiline tooltips for your controls in a separate method, called from Form_Load.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: