Visual Basic .NET Forums    

Go Back   Visual Basic .NET Forums > VB.NET > Component Development

VB.NET Forums Newsletter Signup:
Email address:


Component Development Development of components with VB.NET

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-27-2008, 4:52 PM
VB.NET Forum Enthusiast
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Jun 2008
Posts: 59
Reputation: 10
newguy is on a distinguished programming path ahead
Default MaxLength problem in user control.

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?
__________________

If you find your way you can't be lost...
Close Counts for; Horseshoes, Handgranades, and Nuclear Missiles!
Reply With Quote
  #2 (permalink)  
Old 12-01-2008, 8:32 PM
VB.NET Forum Enthusiast
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Jun 2008
Posts: 59
Reputation: 10
newguy is on a distinguished programming path ahead
Default

Appearently btn_click events that add text override the MaxLength property.
So check the text.length in the click event before adding the text...
__________________

If you find your way you can't be lost...
Close Counts for; Horseshoes, Handgranades, and Nuclear Missiles!
Reply With Quote
  #3 (permalink)  
Old 12-02-2008, 8:01 AM
JohnH's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 36
Posts: 8,138
Reputation: 876
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

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.
Quote:
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:
Quote:
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.
__________________
See this thread about how to use forum markup codes for code blocks etc (present the problem/post properly )
Some useful links: Learning videoes, WMI Code Creator, MSDN, The Code Project, WindowsClient.net, ASP.net, W3 Schools, Regular-Expressions.info, GDI+ FAQ


DR. WEIR: Download it to a non-networked, firewalled computer.
TECHNICIAN: Yes, ma'am.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -4. The time now is 2:17 AM.




Click to advertise here

Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
For advertising opportunities click here.