The one weird thing I noticed about VS2005 is that you can create a dataset via a table adapter and you can drag in the fields in design time to the form, yet the maxlength on the text field remains at the default 32767. Instead of sizing itself to the size of the datacolumn it was mapped to.
I don't know if this bugs anyone else, or perhaps I missed something and it does do this automatically but here's a helper function I created that sets the sizes programmatically.
Expand|Select|Wrap|Line Numbers
- Public Sub SizeTextFields(ByRef pForm As Form, ByVal pDT As DataTable)
- Dim ctl As Control
- Dim ctlTxt As TextBox
- For Each ctl In pForm.Controls
- If TypeOf ctl Is TextBox Then
- ctlTxt = ctl
- Try
- ctlTxt.MaxLength = pDT.Columns(ctlTxt.DataBindings("Text").BindingMemberInfo.BindingField.ToString()).MaxLength
- Catch ex As Exception
- 'no big deal
- End Try
- End If
- Next
- End Sub