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
close icon

Currency Formatting

Hi,

I am using grouping grid control. I have used the cell type as Currency & Currency symbol as £. but I want to display value 1000 as £1 i.e thousand pounds.....is it possible in GGC..?
My actual value is 1000 but want to display it as £1...but calculations should be done on actual value i,e 1000

4 Replies

HA haneefm Syncfusion Team April 3, 2007 03:56 PM UTC

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


KG Kunal Gandhi May 31, 2007 11:37 AM UTC

Hi,

We have been trying to change color of a currency textbox in the grid, but to no avail. Could you please let me know if we can change the color? If so, how?

Thank you in advance,

Kunal
>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


KG Kunal Gandhi May 31, 2007 11:39 AM UTC


I meant the color of the text in currency textbox.

Thanks,

Kunal
>Hi,

We have been trying to change color of a currency textbox in the grid, but to no avail. Could you please let me know if we can change the color? If so, how?

Thank you in advance,

Kunal
>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


HA haneefm Syncfusion Team May 31, 2007 07:21 PM UTC

Hi Kunal,

You can use Graphics.DrawString method to draw the formatted currenrcy cell text with required color and set the e.Inner.Cancel to true for scratching the default drawing in a grid cell. Below is a code snippet

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);
e.Inner.Graphics.DrawString(e.Inner.DisplayText, e.Inner.Style.GdipFont, new SolidBrush(Color.Red), e.Inner.TextRectangle);
e.Inner.Cancel = true;
}
}
}

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon