Howto limit the a col's length?

  • Thread starter Thread starter Mauricio
  • Start date Start date
M

Mauricio

I have a DataSet bound to a DataGrid.
In the DataSet has a string col that can has 50 characters
at max.
How can I limit the input length in DataGrid?
Thanks.
Mauricio
 
Hi Mauricio,

To limit the length of a column, you can try to set the value of the
DataColumn.MaxLength property. For example, the following code limit the
length of a column to 20 characters:

dataset.Tables[0].Column["Name"] = 20;

If the user exceed the limit when inputing on a datagrid, a dialog box will
be shown.

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Hi Kevin Yu,
It's ok, but I'm using Visual Studio that generate the
DataSet Automatically. Is there a form to limit the col
length using some property window?
Thanks.
Best regards,

Mauricio.
 
Hi Mauricio,

As far as I know, there isn't such a property window to set it. You have to
set it in code.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top