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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Visible text versus actual text

Thread ID:





16735 Jul 22,2004 05:01 PM UTC Jul 23,2004 09:10 AM UTC WinForms 2
Tags: GridControl
Leon Schwartz
Asked On July 22, 2004 05:01 PM UTC

Hi, I was wondering if there was a way to programmatically tell if the text in a given cell is being truncated (trimmed). I am working on something base on your EllipsisCell example, but I only want to show the ellipsis button if the text in that cell is indeed longer than what can be shown. This is in a data-bound grid, if it matters. TIA.

Administrator [Syncfusion]
Replied On July 22, 2004 07:32 PM UTC

You will have to measure teh string yourself. One place you can try to do this is to add an OnDraw override to the EllipsisCellRenderer class. Here is a try at it. It probably needs tweaking some.
protected override void OnDraw(Graphics g, Rectangle clientRectangle, int rowIndex, int colIndex, GridStyleInfo style)
	Rectangle rect = new Rectangle(clientRectangle.X, clientRectangle.Y, clientRectangle.Width + this.Model.ButtonBarSize.Width, clientRectangle.Height);
	int width =  (int) g.MeasureString(style.Text, style.GdipFont).Width;
	if(width < rect.Width)
		style.ShowButtons = GridShowButtons.Hide;
		GridStaticCellRenderer.DrawText(g, style.Text, style.GdipFont, clientRectangle, style, style.TextColor, false); 
		base.OnDraw (g, clientRectangle, rowIndex, colIndex, style);

Leon Schwartz
Replied On July 23, 2004 09:10 AM UTC

Thanks Clay! Didn''t even need to modify your code!


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon