TOOLTIP BACKGROUND ALTERNATION

john rob

Total Post:108

Points:756
Posted by  john rob
C# 
C#
 1039  View(s)
Ratings:
Rate this:

The single tooltip which shows different messages for different controls. Now the Problem is the background image is not fit/suitable to all messages. I supposed to call the draw event of the tooltip for custom size, Font etc.,

I able to successfully call the draw and Popup event of the tooltip for particular message but setting the generalized size for different messages(e.ToolTipText) is unknown to me.

public void tooltip_Popup(object sender, PopupEventArgs e)

{

    e.ToolTipSize = new Size(100, 100);

}

Kindly let me know anybody have any idea about it.

  1. ezra heywood

    Post:145

    Points:1019
    Re: Tooltip background alternation

    Hi john,

    I found the answer for your Problem. The below code of POPUP event will change the tooltipsize according to the text size.

    public void toolTip_Popup(object sender, PopupEventArgs e) {

            using (Font f = new Font("Arial", 12f))

            {

                e.ToolTipSize = TextRenderer.MeasureText(

                    toolTips.GetToolTip(e.AssociatedControl), f);

            }

    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!