Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6055275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:14:49+00:00 2026-05-23T08:14:49+00:00

There might be some workaround for this one – however, I’m not sure what

  • 0

There might be some workaround for this one – however, I’m not sure what it is at the moment. After setting the MaxLength property of a textbox, I am unable to manually exceed the MaxLength of the textBox. On the other hand, if I were to create a loop which programmatically added characters to the textbox – this loop could exceed the maxLength property.

    textBox1.MaxLength = 5;  // I am now unable to manually type in more than 5 chars.

    for (int i = 0; i < 20; i++)
    {
    textBox1.AppendText("D");
    }

// Textbox now holds 20 chars.

Without having to write more lines of code to take a portion of this data, is there a way to ensure that the maxlength property is not exceeded?

Regards,
Evan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T08:14:50+00:00Added an answer on May 23, 2026 at 8:14 am

    MaxLength: Gets or sets the maximum number of characters the user can type or paste into the text box control. (Forms) http://msdn.microsoft.com/en-us/library/system.windows.forms.textboxbase.maxlength.aspx and Gets or sets the maximum number of characters allowed in the text box. (web) http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.textbox.maxlength.aspx

    In other words, that’s the point of MaxLength – it’s all about controlling user input. Since you own the textbox to begin with, you don’t need to set your own hard programmatic restrictions.

    So in short, no – you can’t change this behavior without overriding some other functionality – for instance on OnChanged – or adding the conditional tests like those shown by Ben and Sres.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I guess there might be some overlapping with previous SO questions, but I could
There might be applications that are not suited for Core Data - image manipulation
There might be a really simple solution to this question, but i just don't
I am hoping that there might be an easy way to do this, I
I realise there might be similar questions but I couldn't find one that was
I know this question has kind-a started religious wars in past and there might
This might not be the right place to ask it, but when I open
I recently installed Visual Studio 2010 Pro. There might have been a link to
Both ideas sound very similar to me, but there might be subtle differences or
I know the title isn't very clear. I'm new to PHP, so there might

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.