Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何创建自定义工具提示样式_C#_Popup_Containers_Mouseover_Popupwindow - Fatal编程技术网

C# 如何创建自定义工具提示样式

C# 如何创建自定义工具提示样式,c#,popup,containers,mouseover,popupwindow,C#,Popup,Containers,Mouseover,Popupwindow,如何为文本信息定制工具提示设计?我只知道如何更改背景色或前景色。但我想使用工具提示段落、行、分隔符和图标 如下图所示: class descriptionSpells { ToolTip popup = new ToolTip(); string description = "test"; string range = "15"; string radius = "2"; string castTime = "Instant"; string du

如何为文本信息定制工具提示设计?我只知道如何更改背景色或前景色。但我想使用工具提示段落、行、分隔符和图标

如下图所示:

class descriptionSpells
{
    ToolTip popup = new ToolTip();
    string description = "test";
    string range = "15";
    string radius = "2";
    string castTime = "Instant";
    string duration = "5";

    public descriptionSpells(object sender)
    {
        popup.OwnerDraw = true;
        popup.Popup += new PopupEventHandler(this.OnPopup);
        popup.SetToolTip((Button)sender, description + radius + range + castTime + duration);
        popup.Draw += description_Draw;
    }

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

    private void description_Draw(object sender, DrawToolTipEventArgs e)
    {
        Graphics g = e.Graphics;

        LinearGradientBrush b = new LinearGradientBrush(e.Bounds,
            Color.BurlyWood, Color.Gray, 45f);

        g.FillRectangle(b, e.Bounds);

        g.DrawRectangle(new Pen(Brushes.Black, 1), new Rectangle(e.Bounds.X, e.Bounds.Y,
            e.Bounds.Width - 1, e.Bounds.Height - 1));

        g.DrawString(e.ToolTipText, new Font(e.Font, FontStyle.Bold), Brushes.Silver,
            new PointF(e.Bounds.X + 6, e.Bounds.Y + 6));
        g.DrawString(e.ToolTipText, new Font(e.Font, FontStyle.Bold), Brushes.Black,
            new PointF(e.Bounds.X + 5, e.Bounds.Y + 5));
        b.Dispose();
    }
}

我的脚本:

class descriptionSpells
{
    ToolTip popup = new ToolTip();
    string description = "test";
    string range = "15";
    string radius = "2";
    string castTime = "Instant";
    string duration = "5";

    public descriptionSpells(object sender)
    {
        popup.OwnerDraw = true;
        popup.Popup += new PopupEventHandler(this.OnPopup);
        popup.SetToolTip((Button)sender, description + radius + range + castTime + duration);
        popup.Draw += description_Draw;
    }

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

    private void description_Draw(object sender, DrawToolTipEventArgs e)
    {
        Graphics g = e.Graphics;

        LinearGradientBrush b = new LinearGradientBrush(e.Bounds,
            Color.BurlyWood, Color.Gray, 45f);

        g.FillRectangle(b, e.Bounds);

        g.DrawRectangle(new Pen(Brushes.Black, 1), new Rectangle(e.Bounds.X, e.Bounds.Y,
            e.Bounds.Width - 1, e.Bounds.Height - 1));

        g.DrawString(e.ToolTipText, new Font(e.Font, FontStyle.Bold), Brushes.Silver,
            new PointF(e.Bounds.X + 6, e.Bounds.Y + 6));
        g.DrawString(e.ToolTipText, new Font(e.Font, FontStyle.Bold), Brushes.Black,
            new PointF(e.Bounds.X + 5, e.Bounds.Y + 5));
        b.Dispose();
    }
}

可能重复的thx我会检查你的帖子。我检查了你的帖子,我发现如何制作自定义的工具提示,使其非常棒,但是,当我设置tooltip时,我找不到在哪里可以用文本生成更多行。如果需要显示其他元素,可以使用一些添加的属性扩展自定义工具提示。您可以在此处发布任何示例吗?请我为更新代码编辑了我的第一篇文章。我需要每个字符串都有自己的行。