Formatting Double.Nan values

Hi,
How do I format the contents of a cell containing double values if the double value is NaN? I want to display "" rather than "NaN" in this case. Is there an event I can intercept for this?

2 Replies

AJ Ajish Syncfusion Team August 28, 2007 10:22 PM UTC

Hi Paul,

If you want to display the formatted text in a cell then subscribe the QueryCellFormattedText event and set the e.Text to your new formatted value and then set e.Handled to TRUE to cancel default format. Here is a code snippet to show this,

private void gridControl1_QueryCellFormattedText(object sender, GridCellTextEventArgs e)
{

if (e.Style.CellValue != null)
{
double d;
double.TryParse(e.Style.CellValue.ToString(), out d);

if (double.Equals(d,double.NaN ) )
{
e.Text = "Haha!!!" + d;
e.Handled = true;
}
}
}
Kindly try the above and let me know if this helps in resolving this issue.

Regards,
Ajish.


PS Paul Sullivan August 29, 2007 08:41 AM UTC

Thanks Ajish, that works well!

Loader.
Up arrow icon