Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In a textbox control, I load text from a large file (1025k(1M)).
When I want to write something in that textbox, it does nothing!!
(except when I delete something with "Backspace" (but not with with "Delete"))
How do I correct this strange effect?
Posted
Updated 24-Feb-12 18:31pm
v2

1 solution

By default, a TextBoix has it's MaxLength set to 32767 characters - you are exceeding this by a HUGE margin. If you change this property, it will work as you expect. But I would find a better solution if I was you - a 1M+ text box is going to be a real pain for your users!
 
Share this answer
 
Comments
_Q12_ 25-Feb-12 8:20am    
ok, thanks. I did not see that MaxLength property. I was wondering...what is the maximum number to put there? I like the infinite number a lot. :)
My resolve to the max number:
I made a richtextbox and I done this :
[textBox1.MaxLength = richBox2.MaxLength;]
The string I was able to read from that was:
2147483647
(two billion one hundred forty-seven million four hundred eighty-three thousand six hundred forty-seven) which I find is "the maximum value for a 32-bit signed integer in computing."-(from Wikipedia).
Unfortunately, my textBox1.MaxLength is limited to this:
[textBox1.MaxLength = Int32.MaxValue;] (same as richBox2,btw)
Thanks OriginalGriff. You saved me.
OriginalGriff 25-Feb-12 9:12am    
It's not just the largest number you can put in 32 bits, it's also the largest size any one object can be in .NET - 2GB. So a string can be 2GB, or an array can be 2GB, so you could have an array of 500,000 strings each of which is 2GB, but you can't have a single string which is 2,147,483,648 bytes!

But please - think about your users! One huge text box is impossible to navigate, and very, very slow to load...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900