-1

Currently I am developing a .NET WinForms application in C#. I want to use a form created in designer as a custom tooltip for my project's controls. Is there a way to do it?

monica
  • 53
  • 8

1 Answers1

0

One could argue whether this question is a duplicate of create custom tooltip C# but as it does not provide an example but just a link I think it's good to list the most important points:

To design your custom ToolTip you need to create a new type derived from ToolTip and handle the Draw event where you draw what you need. Rebuild your project and the CustomToolTip should now appear in the Toolbox.

class CustomToolTip : ToolTip
{
    public CustomToolTip()
    {
        this.OwnerDraw = true;
        this.Popup += new PopupEventHandler(this.OnPopup);
        this.Draw += new DrawToolTipEventHandler(this.OnDraw);
    }

    // Sets the size of the CustomToolTip.
    private void OnPopup(object sender, PopupEventArgs e)
    {
        e.ToolTipSize = new Size(100, 100);
    }

    // Draws the CustomToolTip.
    private void OnDraw(object sender, DrawToolTipEventArgs e)
    {
        // your drawing...
    }
}

If you want to use a form for that you'd have create your own logic for showing it on MouseEnter etc. or use 3rd party libraries.

Community
  • 1
  • 1
t3chb0t
  • 16,340
  • 13
  • 78
  • 118
  • If you have some code you can present it and try to fix it. That's why your question gets downvoted, you didn't show that you've already tried something. – t3chb0t Dec 24 '14 at 21:44