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.

Formatting Cell Text

Thread ID:

Created:

Updated:

Platform:

Replies:

61549 May 29,2007 04:43 AM Jul 9,2007 06:07 PM Windows Forms 3
loading
Tags: GridControl
Harshad
Asked On May 29, 2007 04:43 AM

Hi,

I am using GGC. I am binding the entity collection to the grid. Grid contains some numeric columns having sales figures.
User Requirement is- When user select the formatting option as £K then i have to show values /1000 but my data source values should not get changed to /1000. I just need to change display text in cell to cell value/1000 keeping binded cell value as it is.
Is this possible in the GGC. Is there any property which store the formated text without changing the actual cell value..?
Please help.
Thanks
Harshad

haneefm [Syncfusion]
Replied On May 29, 2007 01:23 PM

Hi Harshad,

If you just want to format the text that is displayed, you can handle the TableControlDrawCellDisplayText and set e.DisplayText there to easily control what text is drawn in the cell.

void gridGroupingControl1_TableControlDrawCellDisplayText(object sender, GridTableControlDrawCellDisplayTextEventArgs e)
{
if (e.Inner.Style.CellType == "Currency")
{
if (e.Inner.Style.CellValue != null && e.Inner.Style.CellValue.ToString() != string.Empty )
{
double d;
double.TryParse(e.Inner.Style.CellValue.ToString(),out d) ;
e.Inner.DisplayText = string.Format("£{0}", d / 1000);
}
}
}

Best regards,
Haneef

Harshad
Replied On July 9, 2007 10:47 AM

Hi,

I tried the event but my cell is editable so when user click on the cell to edit the value ,cell display original value and not the formatted one.
What i want to do is user will enter value and i have to save the value *1000 in the datasource and in cell value will not be *1000. This is bounded column.
Please tell me how to do this. I always need to show value /1000 in the editable cell.

haneefm [Syncfusion]
Replied On July 9, 2007 06:07 PM

Hi Harshad.

If you want to display the formatted text in a cell then subscribe the QueryCellFormattedText event and set the e.Text to your new formatted value and then set e.Handled to TRUE to cancel default format. Here is a code snippet to show this

void TableModel_QueryCellFormattedText(object sender, Syncfusion.Windows.Forms.Grid.GridCellTextEventArgs e)
{
if (e.Style.CellType == "Currency")
{
if (e.Style.CellValue != null && e.Style.CellValue.ToString() != string.Empty)
{
double d;
double.TryParse(e.Style.CellValue.ToString(), out d);
e.Text = string.Format("£{0}", d / 1000);
e.Handled = true;
}
}
}

Best regards,
Haneef

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.

;