Question DataGridView Cell ToolTip can it use _Draw and _Popup to customize the Font, etc.

tim8w

Well-known member
Joined
Sep 8, 2020
Messages
133
Programming Experience
10+
Hi,
I have used the ToolTipControl_Draw and ToolTipControl_Popup functions to adjust the Size and Font of tooltips on normal controls like TextEdit. Is there a way to do that for the individual cells on a DataGridView?

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

private void ttControl_Popup(object sender, PopupEventArgs e)
{
    Size newSize;
    newSize = TextRenderer.MeasureText(ttControl.GetToolTip(e.AssociatedControl), new Font("Microsoft Sans Serif", 24.0f, FontStyle.Bold), new Size(int.MaxValue, int.MaxValue), TextFormatFlags.NoPadding);
    newSize = new Size(newSize.Width, newSize.Height + 6);
    e.ToolTipSize = newSize;
}
 
Solution
No there isn't, because there's no ToolTip object exposed. The only thing exposed is the text. You'd have to not use the functionality built into the grid and provide your own ToolTip as you are for other controls. You can call the HitTest method of the grid to determine where the cursor is located and then display an appropriate tip based on that.
No there isn't, because there's no ToolTip object exposed. The only thing exposed is the text. You'd have to not use the functionality built into the grid and provide your own ToolTip as you are for other controls. You can call the HitTest method of the grid to determine where the cursor is located and then display an appropriate tip based on that.
 
Solution
Back
Top Bottom