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.

Visible text versus actual text

Thread ID:

Created:

Updated:

Platform:

Replies:

16735 Jul 22,2004 01:01 PM Jul 23,2004 05:10 AM Windows Forms 2
loading
Tags: GridControl
Leon Schwartz
Asked On July 22, 2004 01:01 PM

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 03:32 PM

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); 
	}
	else
		base.OnDraw (g, clientRectangle, rowIndex, colIndex, style);
}

Leon Schwartz
Replied On July 23, 2004 05:10 AM

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

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.

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.

;