How to limit 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 using DataGrid?
Thanks.
Mauricio
 
Y

Ying-Shen Yu[MSFT]

Hi Mauricio:

Here is a way to limit the length of input on a datagrid column.
The column you input the data in is actually a textbox. We know in textbox
we can limit its length by its property MaxLength.
So you can use the textbox in data grid in the same way. Notice that you
can use a "DataGridTextboxColumn" object which has a property "Textbox".

Here are the detail steps:

First, create a DataGridColumnStyle and add a DataGridTextBoxColumn object:

1. We create a corresponding data grid table styles for this data table,
you may add the table style in DataGridTableStyle Collection Editor, make
sure the MappingName is set to the correct table name.

2. We need define the column styles for the table style; you may add the
column styles in GridColumnStyles property

3. Now you may set the MaxLength for a certain DataGridTextboxColumn like

dataGridTextBoxColumn1.TextBox.MaxLength = 6;


Does this solve your problem? I'd like to follow up with you on this issue,
if you still have problem on it, please be free to reply this thread to let
me know.

Thanks for supporting MSDN newsgroup.



Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending.
 
M

Mauricio

Hi Ying-Shen Yu,
Ok. This solve my problem, but I hope that Microsoft put
this property in property's window of Visual Studio.

Thanks.

Best regards,

Mauricio (Brazil)

create a prop
 

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