# Wednesday, September 23, 2009
« Tip of the Day: WinForms and adding tool... | Main | Interviewing Question of the Day: Virtua... »

So I made a lot of progress on my WinForm application today, and I ran across an issue where I was displaying two tooltips for the same control. I probably would never usually have noticed it, but in this case, I was dynamically setting the contents of the tooltips, and the length of the first tip (which was underneath) was substantially less than the length of the topmost tip.

In debugging the problem, I was looking for a method to clear all previous tooltips associated to the control. I found one (but didn't seem to work), but also noticed a plethora of other cool functionality available to me. Some of the neat properties:

IsBalloon --> Set to true, creates a balloon style tooltip

ToolTipTitle --> A string you can use create a "title" for your tool tip.

ToolTipIcon --> A constant which shows an appropriate icon to the left of the title/tooltip

BackColor --> allows you to set the background color of the tip

There are many more, but I have changed my tooltip routine to look like this:

        public static void SetToolTip(System.Windows.Forms.Control ctrl, string description)

        {

            System.Windows.Forms.ToolTip tt = new System.Windows.Forms.ToolTip();

 

            tt.ShowAlways = false;

            tt.IsBalloon = true;

            tt.UseAnimation = true;

            tt.ToolTipTitle = "Info";

            tt.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info;

 

            tt.SetToolTip(ctrl, description);

 

 

        }

 

The end result went from this:

 

 

 

To this!