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?
Asked
Active
Viewed 454 times
-1
-
2[C# How to use ToolTip](http://www.google.com) great examples can be found here.. try it. – MethodMan Dec 24 '14 at 16:34
-
I know how to add tooltips. What I am asking here is a way to use a form created in designer, instead of the typical tooltip. I googled it a lot but I didn't find anything... – monica Dec 24 '14 at 16:37
-
What framework are you using? WPF, Winforms, ?? – Mark Hall Dec 24 '14 at 16:38
-
[ToolTips WinForms](http://www.dotnetperls.com/tooltip) – MethodMan Dec 24 '14 at 16:39
1 Answers
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.
-
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