all groups > dotnet windows forms > june 2003 >
You're in the

dotnet windows forms

group:

'textBox' Behavior


'textBox' Behavior Chad Christensen
6/30/2003 12:03:00 PM
dotnet windows forms:
I am having a strange problem associated with appending to a textBox using
C# .NET. I am running another program (using the 'Process' class) and the
standard output from the other program is being redirected somewhere else
using threads so I can display it in the Multiline textBox control.

I am sucessfully capturing all the standard output text from the other
program, but when I try to append text to the textBox control using the
AppendText() method, it only allows 32767 characters. In other words, it
just stops appending text at 32767 characters. I have set the 'MaxLength'
variable to a very high number and it does no good. Like I said, I am using
the AppendText() method (from the TextBoxBase class) so that the textBox
scrollbar position will be at the bottom and not always reset its position
at the top (so you can see the latest output text). If I don't use the
AppendText() method, it works just fine with no limits on the amount of
text, but always resets itself to the top so you don't see the latest text,
always just the beginning text.

Re: 'textBox' Behavior Claes Bergefall
7/1/2003 2:58:51 PM
I ran ILDASM and checked the code. Appearently the framework temporarily
sets the max length to 32767 (using a EM_LIMITTEXT message) before
appending the new text (using a EM_REPLACESEL message). After that
it resets the max length to the old value (i.e. to the value of the
MaxLength
property) again. This behaviour is new in 1.1 (I compared it to 1.0).
Does it work in 1.0?


Download Lutz Roeder's .NET Reflector (http://www.aisto.com/roeder/dotnet/)
if you want to see what's happening inside the framework (it's easier to
read than ILDASM)

/claes



[quoted text, click to view]

AddThis Social Bookmark Button