How to detect Ellipsis in FlexGrid.GridData()?

Posted by: freedom93123 on 17 February 2020, 6:25 am EST

    • Post Options:
    • Link

    Posted 17 February 2020, 6:25 am EST - Updated 3 October 2022, 11:56 pm EST

    Hi,

    What I would like to achieve here is to show tool tip text when Ellipsis is detected in the FlexGrid. Is this possible?

    Below attachment is the quick example from Microsoft Outlook:

    Regards,

    Yap

  • Posted 18 February 2020, 5:21 am EST

    Hi Yap,

    We have created a sample as per your comments, please have a look and let us know if you found this useful.

    If you have any other understanding then please let us know and modify the sample accordingly.

    Regards,

    Prabhat Sharma.

    FlexGridToolTip.zip

  • Posted 17 March 2020, 2:59 am EST - Updated 3 October 2022, 11:56 pm EST

    Hi.

    Thank you for your sample but it didn’t resolve my question.

    I have a better example here:

    The image above is C1FlexGrid with UseCompatibleTextRendering = True to achieve the Ellipsis effect.

    And now, I would like the tooltips to show the whole text when I mouse over it.

    Just like the Microsoft Outlook that I posted above.

    Is this possible to achieve?

  • Posted 17 March 2020, 7:14 am EST

    Hi Yap,

    To show the ellipsis in the cell you need to set the Trimming property CellStyle object to StringTrimming.EllipsisCharacter as given below:

    c1FlexGrid1.Styles.Normal.Trimming = StringTrimming.EllipsisCharacter;
    

    If you want to use the default Cell Label to show when there is an ellipsis sign in the cell then you just need to set the ShowCellLabels property of C1FlexGrid to true.

    If you want to show ToolTip when there is Ellipsis sign there in the cell then use the MouseMove event as given below:

     private void C1FlexGrid1_MouseMove(object sender, MouseEventArgs e)
            {
                HitTestInfo hitTestInfo = c1FlexGrid1.HitTest(e.X,e.Y);
                if (hitTestInfo.Type == HitTestTypeEnum.Cell)
                {
                    string measureString = c1FlexGrid1.GetDataDisplay(hitTestInfo.Row, hitTestInfo.Column).ToString();
                    SizeF stringSize = new SizeF();
                    Graphics g = c1FlexGrid1.CreateGraphics();
                    stringSize = g.MeasureString(measureString, c1FlexGrid1.Font);
                    if((stringSize.Width / c1FlexGrid1.Cols[hitTestInfo.Column].WidthDisplay) > 1)
                    {
                          toolTip1.Show(c1FlexGrid1[hitTestInfo.Row, hitTestInfo.Column].ToString(), c1FlexGrid1, hitTestInfo.X + 15, hitTestInfo.Y + 5);
                    }
                    else
                    {
                        toolTip1.Hide(c1FlexGrid1);
                    }              
                }        
            }
    
    

    Please find the attached sample demonstrating the same.

    Regards,

    Prabhat Sharma.

    FlexGridToolTip_Modified.zip

  • Posted 11 May 2020, 9:44 pm EST

    Thanks. I see this does resolve my issue. I will try it out.

    Cheers! :smiley:

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels