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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Retaining Grid Cell Format

Thread ID:

Created:

Updated:

Platform:

Replies:

54525 Jan 10,2007 03:34 PM UTC Jan 12,2007 05:30 AM UTC WinForms 4
loading
Tags: GridControl
Navaneeth Rajkumar
Asked On January 10, 2007 03:34 PM UTC

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 04:32 PM UTC

Ignore previous zip file

22.zip

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

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 08:32 PM UTC

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 05:30 AM UTC

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.

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

;