The ToolTip has a rich interface to perform complex operations by simple means. Indeed, you can easily embed any control into a popup window and use all the power of the .Net not only to custom painting, but also for many other useful things.

The following code demonstrates how to do it.

C# Copy imageCopy
public TestForm()
{
    InitializeComponent();

    //Initialize tooltip
    //...

    //Create a custom control to paint there
    Control control = new Control();
    control.Paint += delegate(object sender, PaintEventArgs e)
    {
        //Some painting routine
        e.Graphics.FillEllipse(Brushes.Pink, control.ClientRectangle);
        using(StringFormat sf = new StringFormat())
        {
            sf.Alignment = StringAlignment.Center;
            sf.LineAlignment = StringAlignment.Center;
            e.Graphics.DrawString("Custom painting works!!!", control.Font, Brushes.Black, control.ClientRectangle, sf);    
        }
    };

    //Associate the control with the button2
    toolTip[button2].CustomControl = control;
    toolTip[button2].Location = new Point(button2.Size.Width, 0);
}

Back to .Net ToolTip HowTo topics