slighty OT - Handling Characters in a Numeric DGV Cell

slighty OT - Handling Characters in a Numeric DGV Cell

Old forum URL: forums.lhotka.net/forums/t/3414.aspx


josh.kodroff posted on Wednesday, August 22, 2007

I have a DGV cell that's bound to an integer property on my CSLA object.  I cannot, for the life of me, figure out how to either prevent or handle the user entering non-numeric characters in the cell. 

The DataErrorEvent appears not to do anything - I try setting the value of the cell where the error occurred, but nothing happens.

I figure there's no way this is as difficult as it appears.  Can someone lend a hand here?

juddaman replied on Wednesday, August 22, 2007

Hi

If you want to prevent the user entering certain characters you should look into creating your own type of custom cell. If you google something like "datagridview masked cell" you should find lots of resources to do with creating your own custom cell/column types. This maybe of interest to: http://msdn2.microsoft.com/en-us/library/aa730881(vs.80).aspx.

Regards

George.

Copyright (c) Marimer LLC