Max Length in datagridview column

I have set various columns on a datagridview to have a maximum length.  It doesn't work; is there something I have to do other than verify the length myself?
rmmarshAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

grayeCommented:
So, you've changed the Resizable property to False and set the Width property to some value... and it ignores you?
0
rmmarshAuthor Commented:
Yes, that's what I mean... I can keep entering data until the cows come home!
0
rmmarshAuthor Commented:
Actually, it's the "maximum input length" field that is not cooperating... width refers to the column width - I want to restrict the actual length of the data that's being entered.
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

grayeCommented:
OK... got it...   I presume this is a DataGridViewTextBox column ?
0
rmmarshAuthor Commented:
yep...
0
nandithaaCommented:
U can use this code to set maximum length....
DataGridViewTextBoxEditingControl TextBoxControl;
 
        private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
        {
            TextBoxControl = e.Control as DataGridViewTextBoxEditingControl;
            if (TextBoxControl != null)
            {
                TextBoxControl.KeyPress += TextBoxCellEditControlKeyPress2;
            }
        }
        private void TextBoxCellEditControlKeyPress2(object sender, KeyPressEventArgs e)
        {
            TextBoxControl.MaxLength = 3; 
        }

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rmmarshAuthor Commented:
Sorry for the delay in responding...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.