Formatting Fractions

I am using the GridControl and showing fractions within cells. I use the QueryCellValue callback for performance reasons. Is it possible to show fractions with a format of one number ontop of the other like:


1
---
2

Instead of 1/2




1 Reply

MW Melba Winshia Syncfusion Team September 16, 2009 12:21 PM UTC

Hi,

Thank you for your interest in Syncfusion Products.

Yes. You can use below code snippet to show fractions with a format of one number on top:




protected void GridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if (e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell || e.TableCellIdentity.TableCellType ==

GridTableCellType.AlternateRecordFieldCell)
{

if(e.TableCellIdentity.Column.Name=="SNo")
{
string s = e.Style.CellValue.ToString();
string[] split = s.Split(new char[] { '/' });
e.Style.CellValue= split[0]+"
---

}

}
}



Please try this and let me know if this helps.

Thanks,
Melba


Loader.
Up arrow icon