Allow textbox to go past 32K characters?

  • Thread starter Thread starter Adam Clauss
  • Start date Start date
A

Adam Clauss

I've an application which is using a multiline textbox to log the status of a fairly long procedure. "Updates" are made to the
status by calling textbox.AppendText.

As my task is fairly lengthy, I go well past the default max text length of the textbox. According to the documentation, setting
MaxLength = 0 will increase this to basically the limit of available memory. So, in the form designer, I set the MaxLength property
equal to 0.

However, this has not made any difference, as it still stops adding text at 32K characters. Any ideas why it would still be
limiting me? Or suggestions on an alternative method for providing the status?
 
Well, the Text property is a String. A String's Length property is an
Integer - meaning the Length can not be longer then roughly 32K (the maximum
value for an integer). So it would seem that this is a limitation of the
String class, though I am not sure whether or not this is explicitly
mentioned.

Adam Clauss said:
I've an application which is using a multiline textbox to log the status
of a fairly long procedure. "Updates" are made to the
status by calling textbox.AppendText.

As my task is fairly lengthy, I go well past the default max text length
of the textbox. According to the documentation, setting
MaxLength = 0 will increase this to basically the limit of available
memory. So, in the form designer, I set the MaxLength property
equal to 0.

However, this has not made any difference, as it still stops adding text
at 32K characters. Any ideas why it would still be
 
Hmm... no, it does not mention this at all.

From MSDN doc on MaxLength:
Windows NT 4.0, Windows 2000, Windows Server 2003 family Platform Note: For single line text box controls, if the MaxLength
property is set to 0, the maximum number of characters the user can enter is 2147483646 or an amount based on available memory,
whichever is smaller. For multiline text box controls, the maximum number of characters the user can enter is 4294967295 or an
amount based on available memory, whichever is smaller.

Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition Platform Note: For single line text box controls, if
the MaxLength property is set to 0, the maximum number of characters the user can enter is 32,766 or an amount based on available
memory, whichever is smaller. For multiline text box controls, the maximum number of characters the user can enter is 65,535 or an
amount based on available memory, whichever is smaller.



According to this, since I'm running Windows XP (although not mentioned, I assume it follows with Windows 2000/2003) with a
multiline text box I should get up to 4 billion characters (or memory, but I have 512MB of RAM, I'm not running out at 32K...).
 
And wait... so an int is same as System.Int32 - a signed 32 bit integer. Its max is nowhere near 32K. Its:
-2,147,483,648 to 2,147,483,647 (as quoted per MSDN - and done by hand calculation 2^31).

So it can't be the string length limiting me.
 
Hi Adam, can you post a small program demonstrating your problem? I was able to get a textbox to go past the 32k barrier easily.

The question I have is why are you using a text box for so much text? Does the user need to cut and paste that much text into the app?

Richard
 
Hi Adam,

What OS are you using?

Cheers

Doug Forster

Adam Clauss said:
I've an application which is using a multiline textbox to log the status
of a fairly long procedure. "Updates" are made to the
status by calling textbox.AppendText.

As my task is fairly lengthy, I go well past the default max text length
of the textbox. According to the documentation, setting
MaxLength = 0 will increase this to basically the limit of available
memory. So, in the form designer, I set the MaxLength property
equal to 0.

However, this has not made any difference, as it still stops adding text
at 32K characters. Any ideas why it would still be
 
When I get back to the office tomorrow I'll strip the one I have down and
try to get a small demo app.

The information is not going INTO the app, its a readonly textbox that is
used to display the status of the program (and history of the status, just
adds a new line). I chose it since the main functionality of the program
was recently brought over from a console app. The textbox AppendText method
seemed to be a natural replacement for Console.WriteLine - and it works
great, except for this.

Adam Clauss
(e-mail address removed)
Richard A. Lowe said:
Hi Adam, can you post a small program demonstrating your problem? I was
able to get a textbox to go past the 32k barrier easily.
The question I have is why are you using a text box for so much text?
Does the user need to cut and paste that much text into the app?
 
Windows XP

Adam Clauss
(e-mail address removed)

"Doug Forster" <doug at _ZAPTHIS_
toniq_ZAPTHIS_DOT_ZAPTHIS_co_ZAPTHIS_DOTnz> wrote in message
 
Hi Adam

I did convert a console application few weeks ago and i found that using the
ListBox control was much more efficient than using a textBox...

if you really want to use a textbox maybe a string builder object would give
you better performance.

But as I said the listBox control is really cool...

Anyway hope this helps!

Keep us posted about what you find for a solution!

Thanks

Marc-andre Poupier, MCSE,MCT
mapoupier@NOSPAM_guardianmicro.com


Adam Clauss said:
I've an application which is using a multiline textbox to log the status
of a fairly long procedure. "Updates" are made to the
status by calling textbox.AppendText.

As my task is fairly lengthy, I go well past the default max text length
of the textbox. According to the documentation, setting
MaxLength = 0 will increase this to basically the limit of available
memory. So, in the form designer, I set the MaxLength property
equal to 0.

However, this has not made any difference, as it still stops adding text
at 32K characters. Any ideas why it would still be
 
Textboxes are limited to 32K on windows 98, But under windows 200 and
higher, maxlength should go past 2GB.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
Adam Clauss said:
I've an application which is using a multiline textbox to log the status
of a fairly long procedure. "Updates" are made to the
status by calling textbox.AppendText.

As my task is fairly lengthy, I go well past the default max text length
of the textbox. According to the documentation, setting
MaxLength = 0 will increase this to basically the limit of available
memory. So, in the form designer, I set the MaxLength property
equal to 0.

However, this has not made any difference, as it still stops adding text
at 32K characters. Any ideas why it would still be
 
My apologies for not following up on this sooner. Unfortunately the schedule for this application got pushed up, so I was not able
to further test what was wrong with the textbox.

I switched over to the listbox as you suggested, and it is working great so I will stick with it.

Thank you for your advice!
 
Well, since this is a multiline textbox, it would actually be 65K on Windows 98 according to the MSDN - but that is irrelevant here
as I'm on Windows XP.
 
Back
Top