INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

DataGridView Column MaxInputLength Not Working

DataGridView Column MaxInputLength Not Working

(OP)
VS 2008. I have the following two columns in my datagridview. No matter what order I add them to my grid, whichever is the second column only allows me to enter two characters, not 20. I can even separate them by another column and it has no effect. I am using an SQL data adapter to get the data from the database. I can also open the table in SQL and enter 20 characters and they show up in the grid, but when I try and change the value in the grid it only allows 2 characters. I have a couple of other coulumns in the same grid and they work fine. Any ideas? Is my grid or form corrupted? Am I missing something obvious?

CODE

Dim dgvTextBox As DataGridViewTextBoxColumn
... More columns
dgvTextBox = New DataGridViewTextBoxColumn
dgvTextBox.Name = "SerialNbr1"
dgvTextBox.HeaderText = "Serial # Part 1"
dgvTextBox.Width = 90
dgvTextBox.MaxInputLength = 20
dgvTextBox.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft
dgvTextBox.DataPropertyName = "SerialNbr1"
dgvTextBox.Visible = True
dgvUnit.Columns.Add(dgvTextBox)
ColCount = ColCount + 1
SerialNbr1ColNbr = ColCount

dgvTextBox = New DataGridViewTextBoxColumn
dgvTextBox.Name = "SerialNbr2"
dgvTextBox.HeaderText = "Serial # Part 2"
dgvTextBox.Width = 90
dgvTextBox.MaxInputLength = 20
dgvTextBox.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft
dgvTextBox.DataPropertyName = "SerialNbr2"
dgvTextBox.Visible = True
dgvUnit.Columns.Add(dgvTextBox)
ColCount = ColCount + 1
SerialNbr2ColNbr = ColCount
... More columns

dgvUnit.DataSource = bsDetail 

Auguy
Sylvania/Toledo Ohio

RE: DataGridView Column MaxInputLength Not Working

(OP)
Ahh crap. Found it. I had a rogue "dgvTextBox.MaxInputLength" mixed in with a combo box definition several columns after these text boxes.

Auguy
Sylvania/Toledo Ohio

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close