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.

Retaining Grid Cell Format

Thread ID:

Created:

Updated:

Platform:

Replies:

54525 Jan 10,2007 10:34 AM Jan 12,2007 12:30 AM Windows Forms 4
loading
Tags: GridControl
Navaneeth Rajkumar
Asked On January 10, 2007 10:34 AM

Hi,
I am using a GridDataBoundGrid to display a few Dollar Values.. I am writing some code in the model_QueryCellInfo handler to format the cell before displaying.. Ex: if the value is -10.5, it shows as (10.5) and the color is red. Suppose it is an amount it adds a $ and if its a Float, it rounds off the value to 5 decimals.. Please view attached .txt file for sample code..

Open before.bmp. Thats the right format.. when I click one of the cells and sort the grid by double clicking the header, the cell format is lost.. check after.bmp for the output after sorting.

Is there anyway to fix this? I am using 4.2.0.60..

Thanks
Navaneeth




17.zip

Navaneeth Rajkumar
Replied On January 10, 2007 11:32 AM

Ignore previous zip file

22.zip

Administrator [Syncfusion]
Replied On January 11, 2007 05:49 AM

Hi Navaneeth,

Instead setting the Currency/F5 format in a textbox cell, try setting the CellType = "Currency" and Let me know if this helps.

Here is a code snippet.

private void Model_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
if(format == "Dollar")
{
e.Style.CellType = "Currency";
}
else
{
e.Style.CellType = "Currency";
e.Style.CurrencyEdit.CurrencyDecimalDigits = 5;
}
}

Also refer our shipped CurrencyCells browser sample which shows you how to use Syncfusion’s CurrencyEdit control in grid cells.
\Syncfusion\Essential Studio\4.4.0.49\windows\Grid.Windows\Samples\CellTypes\CurrencyCells\cs

Best Regards,
Haneef

Navaneeth Rajkumar
Replied On January 11, 2007 03:32 PM

Haneef,
The below is the code I am using.. The first time the grid is displayed, there is no problem.. Only when the grid is sorted by double clicking the header(and when the current cell is in the sorted column), the cells lose their format. And I am using 4.2.0.60..

if(format == "Dollar")
{
e.Style.CellType = "Currency";
if(System.Convert.ToDouble(e.Style.CellValue)< 0)
e.Style.TextColor = Color.Red;
}
else if(format == "Float")
{
e.Style.Format = "F5";
if(System.Convert.ToDouble(e.Style.CellValue)<0)
e.Style.TextColor = Color.Red;
}


>Hi Navaneeth,

Instead setting the Currency/F5 format in a textbox cell, try setting the CellType = "Currency" and Let me know if this helps.

Here is a code snippet.

private void Model_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
if(format == "Dollar")
{
e.Style.CellType = "Currency";
}
else
{
e.Style.CellType = "Currency";
e.Style.CurrencyEdit.CurrencyDecimalDigits = 5;
}
}

Also refer our shipped CurrencyCells browser sample which shows you how to use Syncfusion’s CurrencyEdit control in grid cells.
\Syncfusion\Essential Studio\4.4.0.49\windows\Grid.Windows\Samples\CellTypes\CurrencyCells\cs

Best Regards,
Haneef

Administrator [Syncfusion]
Replied On January 12, 2007 12:30 AM

Hi Navaneeth,

We are not sure of what be might be causing this strange behavior without a working sample. Are you setting any property of the cell dynamically using PrepareViewStyle event? Please post us a sample showing this problem, which will help us to find the issue and resolve this.

Thanks for your patience.

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.

;