Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGridView Column MaxInputLength Not Working

Status
Not open for further replies.

Auguy

Programmer
May 1, 2004
1,206
US
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
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top