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. Image for the cookie policy date

Cell Formatting

I wonder how to format a cell to display currency or date. In the samples, the following lines are coded: this[row, col].CellValueType = typeof(double); this[row, col].Format = "C"; ALthough these 2 lines do work, what if the selection contain non-digit data? Things get even worses if I turn on the floatcell model. The attached form illustrates this problem, I had to use try, catch to protect ChangeCells functions. Even this workaround works, When I start to type in the formatted area (in my example, row 1, col 1), another exception strikes. I had to use ThreadException to catch it, otherwise, my system will crash. Please advise. Thanks

1 Reply

AD Administrator Syncfusion Team April 29, 2003 10:34 AM

Hong, I looked into this issue. Regarding the exception not being catched while displaying (or when floating cells are calculated), this was a bug. The exception was not correctly handled and I fixed that. Regarding the issue of users entering text that does not match the cells style, I decided that it is best to add an option that lets you specify whether you want the cell to accept invalid entries as plain string or if a warning message box should be displayed. So, with the 1.6 version (should be out within a week or so) you can then set style.StrictValueType = false. When you do this the text will be stored as string and no warning is displayed. The default behavior will still be that this property is true and a warning message displayed. You will be able to fine tune and further customize this behavior by handling the SaveCellFormattedText event. In this events handler you could then decide on a cell by cell basis what to do and possibly also change the underlying cells CellValueType based on the contents of the input text. See the documentation for SaveCellFormattedText for an example in the 1.6 version then when it is out. Stefan

Loader.
Live Chat Icon For mobile
Up arrow icon