Resolved Tooltip Draw routine not firing?

tim8w

Well-known member
Joined
Sep 8, 2020
Messages
133
Programming Experience
10+
Hi,
I wanted to change the font of the ToolTip control. So I set the OwnerDraw in the control to "true" and created the Popup and Draw routines:

C#:
        private void ttControl_Draw(object sender, DrawToolTipEventArgs e)
        {
            Font tooltipFont = new Font("Tahoma", 15.0f, FontStyle.Bold);
            e.DrawBackground();
            e.DrawBorder();
            e.Graphics.DrawString(e.ToolTipText, tooltipFont, Brushes.Black, new PointF(2, 2));
        }

        private void ttControl_Popup(object sender, PopupEventArgs e)
        {
            Size newSize;
            newSize = new Size(TextRenderer.MeasureText(ttControl.GetToolTip(e.AssociatedControl), new Font("Tahoma", 15.0f, FontStyle.Bold)).Width,e.ToolTipSize.Height);
            e.ToolTipSize = newSize;
        }

And added the appropriate lines in the Designer:

C#:
            this.ttControl.Draw += new System.Windows.Forms.DrawToolTipEventHandler(this.ttControl_Draw);
            this.ttControl.Popup += new System.Windows.Forms.PopupEventHandler(this.ttControl_Popup);

When I hover over the Label, the Popup event fires, but the Draw does not. Any ideas?
 
See documentation. It's OwnerDraw set to true, and IsBalloon to false.
 
Solution
Back
Top Bottom