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.
Syncfusion Feedback

How to set currency cell in GGC

Thread ID:

Created:

Updated:

Platform:

Replies:

62088 Jun 7,2007 02:43 PM UTC May 6,2008 03:44 PM UTC Windows Forms 5
loading
Tags: Grouping
ejaz
Asked On June 7, 2007 02:43 PM UTC

Hi,

I need to put currency cell in the GGC and need to put currency symbol in the GGC cell.I did that by setting the format property in the following GGC event.

void dgRangePlanGrid_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
e.Style.Format = "£##0.00"
}

this gives the entered value "25.00" in "£25.00" format which is correct.

Now when I select the cell,by mouse,it goes into the edit mode with displaying values as "£25.00",which is incorrect, because I need it to be dispaled as 25.00 after selection and once i edit and change the value say for ex 50.00 it should display againg back in the specified format with the currency symbol eg. "£50.00".

could you pls suggest some help and some code snippet would be very much appreciated.

Thanks,
Ejaz


Administrator [Syncfusion]
Replied On June 7, 2007 03:43 PM UTC

One way to get this behavior is to use TableControlDrawCellDisplayText instead of QueryCellStyleInfo. Here is code that will format a column named "Amount" using this event.


void gridGroupingControl1_TableControlDrawCellDisplayText(object sender, GridTableControlDrawCellDisplayTextEventArgs e)
{
GridTableCellStyleInfo style = e.Inner.Style as GridTableCellStyleInfo;
if ((style.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell
|| style.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell)
&& style.TableCellIdentity.Column.Name == "Amount"
)
{
e.Inner.DisplayText = string.Format("{0:£##0.00}", style.CellValue);
}
}

ejaz
Replied On June 11, 2007 09:23 AM UTC


Hi,

Thanks for you prompt help.
That code is working,But I have two formats
1. "£##0.0" but value divided by thousand
2. "£##0.00"

Now if I have value in the grid in formats one("£##0.0") and two("£##0.00") it works fine but as soon as I click in the cell,it displays me the original value which was there in the grid before format.For example if I have value displayed earlier in the Grid like £25.00 it shows fine but when I apply format one("£##0.0") to show value in format "£##0.0" but divided by 1000(actually it shows the value in format one after dividing the sell value by 1000) it shows fine on the grid but when I click in the cell it shows me the old value £25.00 only which i dont need.I need it should show me the value which it shows after applying the format say £0.0("£##0.0") bacause after dividing 25/1000 we get 0.025 and in the format ("£##0.0") it should show £0.0 and when I click in the cell it should show £0.0 and not £25

Regds,
Ejaz


>One way to get this behavior is to use TableControlDrawCellDisplayText instead of QueryCellStyleInfo. Here is code that will format a column named "Amount" using this event.


void gridGroupingControl1_TableControlDrawCellDisplayText(object sender, GridTableControlDrawCellDisplayTextEventArgs e)
{
GridTableCellStyleInfo style = e.Inner.Style as GridTableCellStyleInfo;
if ((style.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell
|| style.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell)
&& style.TableCellIdentity.Column.Name == "Amount"
)
{
e.Inner.DisplayText = string.Format("{0:£##0.00}", style.CellValue);
}
}


Rajagopal [Syncfusion]
Replied On June 13, 2007 12:48 AM UTC

Hi Ejaz,

The reason for this behavior is that, the TableControlDrawCellDisplayText is just for the display purpose. So, when the cell enters edit mode while you click on the cell it will show the underlying cellvalue and not the displaytext. This is the default behavior. You can try the below property setting to avoid cell getting into edit mode when clicking on the cell, there by retaining the format for the currentcell.

this.gridGroupingControl1.TableModel.Options.ActivateCurrentCellBehavior = GridCellActivateAction.DblClickOnCell;

Let us know if this helps.
Regards,
Rajagopal

-
Replied On May 5, 2008 09:32 AM UTC

I have a case where the currency is 0.0000000.
I need to set such value to "$0.00" by a format string. The format string "$#.##" displays the result as "$" only.
What is the solution to display the value as "$0.00" please? Thanks.


Administrator [Syncfusion]
Replied On May 6, 2008 03:44 PM UTC


Hi MB,

You can set the fomat of your cell to display "$0.00" with the help of the following code.


private void Form1_Load(object sender, EventArgs e)
{
this.gridControl1.ColStyles[1].Text = "000";
this.gridControl1.ColStyles[1].Format = "C";
this.gridControl1.ColStyles[1].CellValueType = typeof(double);
}


Please refer the sample in the below link that illustrates the above.

http://websamples.syncfusion.com/samples/Grid.Windows/F62088/main.htm

Please let me know if you have any questions.

Regards,
Asem.


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.

Warning Icon 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.Close Icon

;