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.

Currency Formatting

Thread ID:

Created:

Updated:

Platform:

Replies:

59013 Apr 3,2007 09:10 AM May 31,2007 03:21 PM Windows Forms 4
loading
Tags: GridControl
Harshad
Asked On April 3, 2007 09:10 AM

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

haneefm [Syncfusion]
Replied On April 3, 2007 11:56 AM

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

Kunal Gandhi
Replied On May 31, 2007 07:37 AM

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

Kunal Gandhi
Replied On May 31, 2007 07:39 AM


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

haneefm [Syncfusion]
Replied On May 31, 2007 03:21 PM

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

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.

;