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.

cells truncating number instead of showing indication cell too short

Thread ID:

Created:

Updated:

Platform:

Replies:

6139 Aug 1,2003 10:08 AM Aug 2,2003 03:40 PM Windows Forms 3
loading
Tags: GridControl
Lou Ann Sinicrope
Asked On August 1, 2003 10:08 AM

I was wondering if there is a grid property to set so that when the column width is too small to display the entire number in the grid cell, it shows some indication instead of just truncating the number. Excel handles it by displaying ######.

Administrator [Syncfusion]
Replied On August 1, 2003 11:00 AM

There is no property to handle this. You would have to use events to do this. One event would be QueryCellFormattedText. You could also do it in PrepareViewStyleInfo.

Lou Ann Sinicrope
Replied On August 2, 2003 01:12 PM

How would I go about handling this event to get the result I'm looking for?

Administrator [Syncfusion]
Replied On August 2, 2003 03:40 PM

Since you have to use Graphics.MeasureString to compute the reqired width, it makes more sense to use DrawCell to handle this work since the Graphics object is already available in it. If you use PrepareViewStyleInfo, then you would have to call CreateGraphics to get a Graphics object. In DrawCell, you can test the text to be drawn and if it will not fit, replace it with asterisks. here is a snippest that does this in column 2.
private void gridDataBoundGrid1_DrawCell(object sender, GridDrawCellEventArgs e)
{
	if(e.ColIndex == 2 && e.RowIndex > 0)
	{
		SizeF sz = e.Graphics.MeasureString(e.Style.Text, e.Style.GdipFont);
		if(sz.Width > e.Bounds.Width - e.Style.TextMargins.Left - e.Style.TextMargins.Right)
		{
			e.Style.Text = new string('*', e.Style.Text.Length);
		}
	}
}

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.

;