Anyone have any idea on how to change the font of a dynamically created ToolTip
? What I usually do in Label
is
string arialUnicodeFontFace = "Arial Unicode MS";
Font unicodeFont = new Font(arialUnicodeFontFace, 8);
if (unicodeFont.Name != arialUnicodeFontFace)
unicodeFont = new Font("NSimSun", 8);
Label lbl = new Label();
lbl.Font = unicodeFont;
for (int x = 0; x < dt.Rows.Count; x++)
{
TextBox txt = new TextBox();
txt.Name = dt.Rows[x]["field_name"].ToString();
txt.Width = 200;
txt.Height = 10;
ToolTip tooltip = new ToolTip();
foreach (DataRow row in dtchnge.Rows)
{
if (dt.Rows[x]["definition"].ToString() == row["term"].ToString())
{
tooltip.SetToolTip(txt, row["language_based_term"].ToString());
}
}
The basic ToolTip
is drawn by the Operating System, if you want to Customize it you will need to set the OwnerDraw property to true and handle the Custom Fonts in the Draw Event like the MSDN example shows.
From first Link:
Usually, a ToolTip is drawn by the operating system, but to customize the appearance of the ToolTip you can set the OwnerDraw property to true and handle the Draw event.
The IsBalloon property takes precedence over the OwnerDraw property. If both are set to true, the ToolTip will be displayed using a balloon window rather than an owner drawn window.