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.

Cell Renderer

Thread ID:

Created:

Updated:

Platform:

Replies:

38478 Dec 13,2005 05:31 PM Dec 13,2005 08:54 PM Windows Forms 3
loading
Tags: GridControl
Stephen
Asked On December 13, 2005 05:31 PM

I''m using a GridGroupingControl and I am wondering what is the easiest way to create a custom renderer. There is no user input in the grid and all the data is driven by a datasource. I need this renderer: 1) Depending on whether the value in the column is less than or greater than a billion, display "M" or "B" at the end. So 100,000 -> .1M. 1,000,000,000 -> 1B

Administrator [Syncfusion]
Replied On December 13, 2005 06:22 PM

The simplest way to handle this is to subscribe to the TableControlDrawCellDisplayText.
private void gridGroupingControl1_TableControlDrawCellDisplayText(object sender, GridTableControlDrawCellDisplayTextEventArgs e)
{
	GridTableCellStyleInfo style = e.Inner.Style as GridTableCellStyleInfo;
	if(style != null && (style.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell 
		|| style.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell)
		&& style.TableCellIdentity.Column != null
		&& style.TableCellIdentity.Column.Name == "Col1")
	{
		double d = (double)style.CellValue;
		if(d > 1000000000)
		{
			e.Inner.DisplayText = string.Format("{0:#.##}B", d / 1000000000);
		}
		else
		{
			e.Inner.DisplayText = string.Format("{0:#.##}M", d / 1000000);
		}
	}
}

Stephen
Replied On December 13, 2005 08:02 PM

Thanks Clay. Is there a way to do this using a renderer class that I can just attach to whichever columns I choose? Thanks. >The simplest way to handle this is to subscribe to the TableControlDrawCellDisplayText. > >
>private void gridGroupingControl1_TableControlDrawCellDisplayText(object sender, GridTableControlDrawCellDisplayTextEventArgs e)
>{
>	GridTableCellStyleInfo style = e.Inner.Style as GridTableCellStyleInfo;
>	if(style != null && (style.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell 
>		|| style.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell)
>		&& style.TableCellIdentity.Column != null
>		&& style.TableCellIdentity.Column.Name == "Col1")
>	{
>		double d = (double)style.CellValue;
>		if(d > 1000000000)
>		{
>			e.Inner.DisplayText = string.Format("{0:#.##}B", d / 1000000000);
>		}
>		else
>		{
>			e.Inner.DisplayText = string.Format("{0:#.##}M", d / 1000000);
>		}
>	}
>}
>

Administrator [Syncfusion]
Replied On December 13, 2005 08:54 PM

You could use this code from a renderer but it might be simpler to just wrap it in a helper class. Here is a little sample. http://www.syncfusion.com/Support/user/uploads/GGC_TextBoxFilter_45059fa0.zip

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.

;