Formatting Double cellType

Hi,

I'm creating an application that have a grid which user can change the cell format similar to Excel.

The only issue is, if a cell's CellValueType is set to Double, whenever user apply customize format (i.e "mm:ss"), the cell text will display the format text itself. This is undesirable.

i.e:
CellValueType = typeof(Double)
CellText = 101
Format = "mm:ss"

Displayed Text = mm:ss

In Excel, the cell value is converted to a DateTime value and then applies the format. Is there a way I can achieve this? or Is there a way I can block applying the format so that it won't display the format text itself?

Attached is the sample showing this issue.

Please help.

Thanks,
Jamilah Abdul Rashid




FormatCell.zip

2 Replies

AD Administrator Syncfusion Team May 2, 2008 09:51 AM UTC


Hi Jamilah,

Thanks for the interest in Syncfusion products.

You can set the format of the DateTime using the GridStyleInfo property. Please refer the following code snippet that shows how we can set the format of the DateTime value.


GridStyleInfo style = this.gridControl1.Model[2, 2];
style.CellValueType = typeof(DateTime);
style.Format = "mm:ss";
style.CellValue = DateTime.Now;


Please refer the sample in the below link that illustrates the above.

http://websamples.syncfusion.com/samples/Grid.Windows/F73187/main.htm

Please let me know if this helps.

Regards.
Asem.




AD Administrator Syncfusion Team May 8, 2008 01:35 AM UTC

Thanks Asem.
You gave an idea on fixing this.


Loader.
Up arrow icon