Howto limit the a col's length?

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
 
K

Kevin Yu [MSFT]

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."
 
M

Mauricio

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.
 
K

Kevin Yu [MSFT]

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."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top