TextBox Capacity?

  • Thread starter Thread starter Patrick de Ridder
  • Start date Start date
Well the 'Text' property is of type string and a string has a 'Length'
property of type int and int.MaxValue is over 2 billion, which could
corrilate to an approximately 2GB string. So the point is that you'll
proboly hit an "OutOfMemoryException" before reaching its limit (at arround
700 million characters).

- Noah Coad -
Microsoft MVP
 
Thank you Noah for responding.

In the Properties Box there is a value MaxLength which is standard set to
32767.
Presumably they are characters. So do I need to change that vale if I want
to be sure that the textBox doesn't run out of capacity? Or should I measure
up the string all the time and add a bit of capacity when a threshold is
reached?

Patrick.
 
That's the limit on how many characters the user can enter, not the number
that can be displayed.

-Noah
 
Just give it a try. You can write some very simple test code, like this.

textBox1.Text = "".PadLeft(1000000 - 6, '-');
textBox1.Text += "ending";
 
Well, it took one heck of a time. And I could bake beans on
the processor afterwards. So the limitation is not so much
capacity, as it is speed. It just becomes non-feasible. I tried
1,000,000 characters by the way.
 
Back
Top