【问题标题】:how to remove underline from link label in compact framework (windows ce)如何从紧凑框架中的链接标签中删除下划线(Windows ce)
【发布时间】:2017-07-06 05:22:17
【问题描述】:

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

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

知道如何去掉下划线和改变字体颜色吗?

【问题讨论】:

    标签: c# .net compact-framework windows-ce


    【解决方案1】:

    一种简单的方法是从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#而不是VB
    • 已转换。不过这应该是微不足道的。
    猜你喜欢
    • 2014-01-17
    • 2015-11-10
    • 2012-06-06
    • 1970-01-01
    • 1970-01-01
    • 2012-03-06
    • 1970-01-01
    • 2013-11-10
    • 1970-01-01
    相关资源
    最近更新 更多