MaxLength problem in user control.

newguy

Well-known member
Joined
Jun 30, 2008
Messages
611
Location
Denver Co, USA
Programming Experience
1-3
Ok I have a textbox on a user control, and I set the MaxLength property to 3, but it does not stop at 3 when the program is running. These controls are added at runtime and I have even added the maxLength property in code when building the control. Any ideas?
 
Appearently btn_click events that add text override the MaxLength property.
So check the text.length in the click event before adding the text...
 
You had to find out emperically now, but next time you check the help documentation, which in this case in very clear about your inquiry, for example if you press F1 on MaxLength property in designer or code.
Gets or sets the maximum number of characters the user can type or paste into the text box control.
With even more explicit info in Note:
In code, you can set the value of the Text property to a value that has a length greater than the value specified by the MaxLength property. This property only affects text entered into the control at run time.
 
Back
Top