自定义工具提示的后续显示在边框周围有丑陋的黑色边缘

时间:2013-06-27 17:32:05

标签: c# .net tooltip

我创建了一个简单的Tooltip类,我希望通过更多的功能来增强它,但只有一个基本的工具提示我遇到了一个问题,它在第二次或之后出现时沿边界变得难看。它第一次显示,看起来是正确的。

谁能告诉我为什么会这样?

using System;
using System.Data;
using System.Linq;
using System.Text;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;
using System.Threading.Tasks;
using System.Drawing.Drawing2D;
using System.Collections.Generic;

class CToolTip : ToolTip
{

    public CToolTip()
    {
        this.OwnerDraw = true;
        this.Popup += new PopupEventHandler(this.OnPopup);
        this.Draw += new DrawToolTipEventHandler(this.OnDraw);
    }

    private void OnPopup(object sender, PopupEventArgs e)
    {
        e.ToolTipSize = new Size(200, 200);
    }

    private void OnDraw(object sender, DrawToolTipEventArgs e)
    {
        e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
        e.Graphics.FillRectangle(Brushes.LightYellow, new Rectangle(0, 0, 200, 200));
    }
}

我将CToolTip和一个按钮添加到表单中。为悬停事件添加了事件处理程序,并将其显示在按钮悬停上。

this.button1.MouseHover += new System.EventHandler(this.button1_MouseHover);

    private void button1_MouseHover(object sender, EventArgs e)
    {
        cTip.SetToolTip(button1, "This is a test");
    }

1 个答案:

答案 0 :(得分:0)

最终成了这条线。当我删除它时,问题就消失了。

e.Graphics.SmoothingMode = SmoothingMode.HighQuality;