The following example shows how to change control’s tooltip font size in your windows application. In this example you can see that large tooltip message on the textbox control hover.
To increase the font size of the tooltip, you need to use the Draw and Popup event and set the ToolTip.OwnerDraw property value to true and the IsBalloon property to false.
The Draw event of the tooltip occurs after the Popup event. I am customizing the font with the help of Graphics object of the DrawToolTipEventArgs event argument in the Draw event. See this:
- string temptooltiptext = "";
- private void toolTip1_Draw(object sender, DrawToolTipEventArgs e)
- {
- Font tooltipFont = new Font("calibri", 15.0f);
- e.DrawBackground();
- e.DrawBorder();
- temptooltiptext = e.ToolTipText;
- e.Graphics.DrawString(e.ToolTipText, tooltipFont, Brushes.Black, new PointF(2, 2));
- }
- private void toolTip1_Popup(object sender, PopupEventArgs e)
- {
- e.ToolTipSize = TextRenderer.MeasureText(toolTip1.GetToolTip(e.AssociatedControl), new Font("calibri", 15.0f));
- }
Additionally you can also customize the appearance of the tool tip by using the graphics object. You can draw lines, rectangles and shapes in the tooltip.