Completed
Last Updated: 01 Oct 2014 12:59 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 16 Jun 2014 07:37
Category: GridView
Type: Bug Report
0
FIX. RadGridView - ToolTipText is missing in the DrawToolTipEventArgs in the ToolTip.Draw event
To reproduce:

public Form1()
{
    InitializeComponent();
    radGridView1.ToolTipTextNeeded += radGridView1_ToolTipTextNeeded;
}

private void radGridView1_ToolTipTextNeeded(object sender, ToolTipTextNeededEventArgs e)
{
    GridDataCellElement cell = sender as GridDataCellElement;
    if (cell != null)
    {
        e.ToolTipText = cell.Value.ToString();
        toolTipText = e.ToolTipText;
        e.ToolTip.OwnerDraw = true;
        e.ToolTip.Draw += ToolTip_Draw;
        e.ToolTip.Popup += ToolTip_Popup;
    }
}

private void ToolTip_Popup(object sender, PopupEventArgs e)
{
    e.ToolTipSize = TextRenderer.MeasureText(toolTipText + "   ", newFont);
}

Font newFont = new Font("Arial", 15f, FontStyle.Bold);
string toolTipText = string.Empty;

private void ToolTip_Draw(object sender, DrawToolTipEventArgs e)
{
    e.Graphics.FillRectangle(SystemBrushes.Control, e.Bounds);
    e.DrawBorder();         
    using (StringFormat sf = new StringFormat())
    {
        sf.Alignment = StringAlignment.Center;
        sf.LineAlignment = StringAlignment.Far;
        sf.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.None;
        sf.FormatFlags = StringFormatFlags.NoClip;

        e.Graphics.DrawString(e.ToolTipText, newFont, Brushes.Red, e.Bounds, sf);
    }
}

0 comments