We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Tooltip of the cell text when text is longer than cell width

Thread ID:

Created:

Updated:

Platform:

Replies:

107729 Mar 13,2013 03:13 PM UTC May 14,2018 12:55 PM UTC Windows Forms 6
loading
Tags: Grouping
Gaukhar Massabayeva
Asked On March 13, 2013 03:13 PM UTC

Hi,
 
I am looking for a way to
 
1) set a tooltip text (something along the lines of e.Style.CellTipText = e.Style.Text) IF the Text inside the cell is longer than the width of that cell.
 
2) the tooltip display time should be customisable.
 
Please let me know how can this be achieved. Thank you
 

Gaukhar Massabayeva
Replied On March 14, 2013 01:50 PM UTC

Oh and the tooltip should be available in nested rows as well.

Vinish Kumar K [Syncfusion]
Replied On March 18, 2013 05:34 PM UTC

Hi Gaukhar Massabayeva,

 

Thank you for your interest in Syncfusion.

 

Sorry for the inconvenience caused with delay we have analyzed your query with the provided details. You can set the tooltip for the cells which contain the large text using the PrepareViewSyleInfo event please refer the following codes for your references.

 

void gridControl1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)

        {

            //e.Style.CellTipText = e.Style.Text;

 

            GridCurrentCell cc = this.gridControl1.CurrentCell;

            GridTextBoxCellRenderer rend = this.gridControl1.CurrentCellRenderer as GridTextBoxCellRenderer;

            if (rend != null)

            {

                int textLength = rend.Control.Text.Length * 6;

                if (this.gridControl1.ColWidths[cc.ColIndex] < textLength)

                    e.Style.CellTipText = e.Style.Text;

                else

                    e.Style.CellTipText = "";

            }

        }

 

 

2. To customize the tooltip text display by the AutoPopDelay code. Please refer the following code to delay.

 

this.gridControl1.CellToolTip.AutoPopDelay = 1000;

 

 

Please refer the attached sample file also which contain the above workaround and let me know if you need any more helps regarding this. We will provide better solution for you.

 

Regards,

Vinish



CS_6420a5d8.zip

Gaukhar Massabayeva
Replied On March 19, 2013 04:54 PM UTC

Hi Thank you for getting back to me.
 
I tried the sample you provided. It works great. However, once the is a column detected whose text exceeds the colwidth for some reason tooltip starts to appear for all cell, even if the text length does not exceed colwidth. :S

Vinish Kumar K [Syncfusion]
Replied On March 20, 2013 07:29 AM UTC

Hi Gaukhar,

 

Sorry for the inconvenience caused.

 

Query

show tool tip on a grid grouping control cell, if text length is greater than the width of the column

We have deeply analyzed your query to show tool tip on a if text length is greater than the width of the column. You can use  the TableControl’s MouseMove event and check whether the cell text length is greater than the cell’s column width, if the text length is larger than the column width then show the tooltip with cell's text.

 

This can be achieved by "Active" property of the tooltip object. The following code explains the same.

 

 

Please use the attached sample file also.

 

Sample file : http://www.syncfusion.com/downloads/Support/DirectTrac/105872/GGC_CustomToolTip-838514140.zip

 

 

Please let me know if you have any concerns.

 

Regards,

Vinish


Adam Thompson
Replied On May 12, 2018 12:48 AM UTC

I would like to achieve the same thing except the code help is not showing in this thread. 

Sindhu Nagarajan [Syncfusion]
Replied On May 14, 2018 12:55 PM UTC

Hi Adam, 

Thanks for contacting Syncfusion support. 

To set tooltip text for cells whose cellvalue is longer than the column width of the grid cell, MouseMove event can be used. To check the cell text length is greater than the cell’s column width, GetMeasureString() method can be used. Please refer to the below code and sample, 
 
Code Example 
//Event Triggering          
gridControl1.MouseMove += GridControl1_MouseMove; 
 
//Event Customization   
private void GridControl1_MouseMove(object sender, MouseEventArgs e) 
{ 
    int row, col; 
    Point p = new Point(e.X, e.Y); 
    gridControl1.PointToRowCol(p, out row, out col); 
    GridStyleInfo style = gridControl1[row, col] as GridStyleInfo; 
    if(style!=null) 
    { 
        Graphics g = gridControl1.CreateGraphics(); 
        float a = g.MeasureString(style.CellValue.ToString(), style.GdipFont).Width; 
        if (this.gridControl1.ColWidths[col] < a) 
        { 
            style.CellTipText = style.Text; 
        } 
        else 
            style.CellTipText = ""; 
    } 
} 


Please let us know if you have any other queries. 

Regards, 
Sindhu  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;