Advertise with us

Tooltip background alternation

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.

Last updated:12/10/2013 12:02:27 AM

1 Answers

ezra heywood
ezra heywood

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);
        }
}

Last updated:12/10/2013 12:02:27 AM

Answer