使用 WinForms,我有一个想要设置到工具提示中的字符串。该字符串由以下行分隔Environment.NewLine
,像这样:
x.ToolTipText = "aaaaaa" + Environment.NewLine + "bbb";
当这个字符串设置为工具提示时,它看起来:
aaaaaa
bbb
但我的问题是,当我希望它本地化为阿拉伯语并且 ToolTip 不支持默认的 RightToLeft 属性时,因此它看起来非常糟糕。我希望它看起来像:
aaaaaa
bbb
Also: String.PadLeft
没有帮助!
任何想法?
第二次尝试。未能使之前的解决方案尝试正确运行。通过使用自定义绘制方法呈现工具提示找到了另一种方法。
设置控件:
string tip = "aaaaaa" + Environment.NewLine + "bbb";
toolTip1.OwnerDraw = true;
toolTip1.Draw += toolTip1_Draw;
toolTip1.SetToolTip(textBox1, tip);
处理抽奖事件:
private void toolTip1_Draw(object sender, DrawToolTipEventArgs e)
{
e.Graphics.FillRectangle(SystemBrushes.Info, e.Bounds);
e.DrawBorder();
e.DrawText(TextFormatFlags.RightToLeft | TextFormatFlags.Right);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)