Retaining Grid Cell Format
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
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
SIGN IN To post a reply.
4 Replies
AD
Administrator
Syncfusion Team
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
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
NR
Navaneeth Rajkumar
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
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
AD
Administrator
Syncfusion Team
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
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
SIGN IN To post a reply.
- 4 Replies
- 2 Participants
-
NR Navaneeth Rajkumar
- Jan 10, 2007 03:34 PM UTC
- Jan 12, 2007 05:30 AM UTC