Right to left tooltip text c#(从右到左的工具提示文本c#)
问题描述
使用 WinForms,我有一个字符串,我想将其设置为 ToolTip.该字符串由 Environment.NewLine
的行分隔,如下所示:
Using WinForms, I have a string which I want to set into a ToolTip. The string is separated by lines with Environment.NewLine
, like so:
x.ToolTipText = "aaaaaa" + Environment.NewLine + "bbb";
当此字符串设置为工具提示时,它看起来:
when this string is set to the ToolTip it looks:
aaaaaa
bbb
但我的问题是当我希望它本地化为阿拉伯语并且 ToolTip 不支持默认的 RightToLeft 属性时,它看起来很糟糕.我希望它看起来像:
But my problem is when I want it to be localized to Arabic and ToolTip does not support the default RightToLeft property, so it looks very bad. I want it to look like:
aaaaaa
bbb
另外:String.PadLeft
没有帮助!
有什么想法吗?
推荐答案
第二次尝试.未能使先前的解决方案尝试正确运行.通过使用自定义绘制方法呈现工具提示找到了另一种方法.
Second try. Didn't manage to get the previous solution attempt to behave correctly. Found an alternate way by rendering the tooltip using a custom draw method.
设置控件:
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);
}
这篇关于从右到左的工具提示文本c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从右到左的工具提示文本c#


基础教程推荐
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01