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

  • Home
  • SEARCH
  • 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 367501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:44:03+00:00 2026-05-12T13:44:03+00:00

I have set the MaxLength property of a textbox in my windows forms application

  • 0

I have set the MaxLength property of a textbox in my windows forms application to 10

I am populating the textbox by reading from a file. However if a read string which is more than 10 characters the textbox still gets populated. But when I manually try to enter a string it works fine (that is, it does not allow more than 10 characters to be entered).

Why is there a difference between these two behaviors? How can I populate my textbox from the file and still have the MaxLength property to be working?

Thanks,
Viren

  • 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-12T13:44:03+00:00Added an answer on May 12, 2026 at 1:44 pm

    From the TextBoxBase.MaxLengthProperty specs:

    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.

    In other words, you must limit the amount of text in code when pulling from a data source.

    For Example:

    string text = "The quick blue smurf jumped over the brown fox.";
    textBox1.Text = text.Substring( 0, textBox1.MaxLength );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently working on a Windows Forms application and I need to have a
I have MyTextBox which is derived from TextBox. I want to set Binding Option
I have set up the Nginx +unicorn for my rails application, it is working
I have set the Timeout property of SmtpClient class, but it doesn't seem to
I have set an environment variable in windows by name sample. Can I get
I have an ASP TextBox with TextMode set to MultiLine. I'm having problems with
I have a TextView with android:maxLength set to 3 and another with android:maxLength set
How do you set the MaxLength and Size of a TextBox in MVC 2?
I have a Sharepoint custom field with a custom string property. It works perfectly,
Currently when I want to set html attributes like maxlength and autocomplete, I have

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.