Can't edit number in DataGrid with format C or N
Posted on 2007-08-04
I have a column in a DataGrid (VB 2003) which has a format of N or C (N displays the number with commas as thousand separators; C, currency, shows the thousands separator plus a $ at the front--using US culture, of course). I have discovered that I cannot edit a number unless the punctuation (commas and dollar sign) are deleted; you can wipe out the current number and put in something new, but you can't, say, delete a 0 to turn 1,500 into 150. Doing edits of a number is fine, though, if the punctuation is gone, either because the number is less than 1000 (and not using C format) or because I've deleted the punctuation. If I leave the comma in, no error is displayed, but when I tab to the next field, the cell reverts to its value before editing.
Does anyone know of a workaround for this? I don't want to eliminate the commas, since the numbers can get into the millions at times, and reading numbers that large without commas is tedious and prone to error. This doesn't happen for ordinary textboxes.