1

How can I make custom tooltip design for text informations? I know only how can I change backColor or foreColor. But I want use for tooltip paragraph, rows, separator and icon.

As this image:

My script:

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();
    }
}
grg
  • 5,023
  • 3
  • 34
  • 50
Radek Tarant
  • 227
  • 1
  • 5
  • 14
  • 3
    possible duplicate of [create custom tooltip C#](http://stackoverflow.com/questions/11644277/create-custom-tooltip-c-sharp) – germi Feb 21 '14 at 12:37
  • thx i will check your post. – Radek Tarant Feb 21 '14 at 12:44
  • I check your post and i found how can i make custom tooltips so its great, but i dont found where i can make more rows with text when i definition SetToolTip. – Radek Tarant Feb 21 '14 at 13:13
  • You could extend the custom tooltip with some added properties if you need additional elements to be displayed. – germi Feb 21 '14 at 13:15
  • Can you post here any examples? please. I edited my first post for update code. I need that each string have own row. – Radek Tarant Feb 21 '14 at 13:32

0 Answers0