Skip to content

Formatable datagrid column - accepts only digits

stoyka

Asked Mar 27, 2006, 3:33 AM EST1 answer
Share
LinkedInX
Hi,

I'd like to add to my datagrid a column that allows only digits to be entered in.
How can I implement this?

Thanks,
Stoyka

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    2 ways I can think to do this off the top of my head. First would be to set up a new event that is triggered when a key is pressed in the datagrid and have it valiadate the string in the cell each time. That way is probably easier but is probably less correct. The approach that I would take(unless it doesnt turn out to work) would be to to make a new class that inheireites from DataGridRow(or whatever it is called!) and instead of using a textbox use a masked textbox and set it to only allow numbers. THen set your datagrid to use your new class instead of the default.
    0