Home All Groups Group Topic Archive Search About

Validating Data in a DataGrid

Author
10 Apr 2006 4:30 AM
Devlei
I have a column in a datagrid that I want to limit the values to
integers from 1 to 5.  What is the best way to do this?

The datagrid is bound to a typed dataset that is populated from an XML
file.

With thanks
Dave

Author
10 Apr 2006 3:57 AM
Chris
Devlei wrote:
> I have a column in a datagrid that I want to limit the values to
> integers from 1 to 5.  What is the best way to do this?
>
> The datagrid is bound to a typed dataset that is populated from an XML
> file.
>
> With thanks
> Dave
>

You need to inherit from datagridtextboxcolumn class and override the
keypress event to handle the keystrokes.  then add this new
datagridtextboxcolumn to you tablestyle instead of the normal class.

Chris
Author
10 Apr 2006 6:21 AM
Cor Ligthert [MVP]
Devlei,

You saw already this tip on our website.

http://www.vb-tips.com/default.aspx?ID=bece831d-6742-4364-bd0d-203ca99d2825

Cor
Author
11 Apr 2006 4:58 AM
Devlei
Hi Cor

Thanks for the link!!

I can follow it all except the CellValidating procedure (last three
lines).

Where do I specify the validation values (ie 1 to 5)?

With thanks
Dave