gpt4 book ai didi

c# - 如何从紧凑框架中的链接标签中删除下划线(windows ce)

转载 作者:行者123 更新时间:2023-11-30 23:11:09 27 4
gpt4 key购买 nike

如何从紧凑框架中的链接标签中删除下划线?由于标签和文本框没有点击事件,我必须使用 linklabel 作为其支持的点击事件。

已尝试 this解决方案,但它不工作显示错误 Error : Operator '!'不能应用于“System.Drawing.FontStyle”类型的操作数

知道如何删除下划线和更改字体颜色吗?

最佳答案

一种简单的方法是从 LinkLabel 继承用户控件并覆盖 OnPaint。其中使用 GDI+ 呈现 LinkLabel 的内容。您仍将拥有 LinkLabel 的所有其他功能,除了文本不会有下划线(如您所愿)。

以下几行内容:

class CustomLinkLabel : LinkLabel
{
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
//MyBase.OnPaint(e)

using (SolidBrush B = new SolidBrush(this.ForeColor))
{
e.Graphics.DrawString(this.Text, this.Font, B, e.ClipRectangle.X, e.ClipRectangle.Y);
}
}
}

关于c# - 如何从紧凑框架中的链接标签中删除下划线(windows ce),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44940361/

27 4 0