I changed in the properties OwnerDraw to true. and added the Draw event.
private void toolTip1_Draw(object sender, DrawToolTipEventArgs e)
{
using (StringFormat sf = new StringFormat())
{
sf.Alignment = StringAlignment.Center;
sf.LineAlignment = StringAlignment.Center;
sf.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.None;
sf.FormatFlags = StringFormatFlags.NoWrap;
using (Font f = new Font("Tahoma", 12))
{
e.Graphics.DrawString(e.ToolTipText, f,
SystemBrushes.ActiveCaptionText, e.Bounds, sf);
}
}
}
First time i put the mouse over a control with a tooltip the text is bigger but then next on other controls the tooltip get black :
before using the Draw event it was working fine but i want to resize the text font size.
CodePudding user response:
You need clear the graphics first.
e.Graphics.Clear(((Control)sender).BackColor);
Or just use the methods defined in DrawToolTipEventArgs
e.DrawBackground();
e.DrawBorder();