gpt4 book ai didi

c# - 在 C# Windows 窗体中更改动态创建的工具提示字体的简单方法?

转载 作者:行者123 更新时间:2023-11-30 17:08:34 24 4
gpt4 key购买 nike

有人知道如何更改动态创建的 ToolTip 的字体吗?我通常在 Label 中做的是

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

最佳答案

基本的 ToolTip 是由操作系统绘制的,如果你想自定义它,你需要设置 OwnerDraw property为真并处理 Draw Event 中的自定义字体如 MSDN 示例所示。

来自第一个链接:

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.

关于c# - 在 C# Windows 窗体中更改动态创建的工具提示字体的简单方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13655905/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com