Quantcast
Channel: AuthorCode » Windows Controls
Viewing all articles
Browse latest Browse all 10

Change tooltip font size in c# windows application

$
0
0

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.

Change tool tip font size

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:

  1. string temptooltiptext = "";
  2. private void toolTip1_Draw(object sender, DrawToolTipEventArgs e)
  3. {
  4.     Font tooltipFont = new Font("calibri", 15.0f);
  5.     e.DrawBackground();
  6.     e.DrawBorder();
  7.     temptooltiptext = e.ToolTipText;
  8.     e.Graphics.DrawString(e.ToolTipText, tooltipFont, Brushes.Black, new PointF(2, 2));
  9. }
  10.  
  11. private void toolTip1_Popup(object sender, PopupEventArgs e)
  12. {
  13.     e.ToolTipSize = TextRenderer.MeasureText(toolTip1.GetToolTip(e.AssociatedControl), new Font("calibri", 15.0f));
  14. }

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.


Viewing all articles
Browse latest Browse all 10

Trending Articles