Increasing limits of textbox

H

Hugh Janus

Hi group,

I have a form with a textbox control on it. I am using the textbox
control with multiline enabled to output the 'log' information for a
long process I am running. My problem is that it all works fine until
the limit of the size of text is reached for the text box. This causes
the textbox to stop update whilst the thread running the process
continues.

Any ideas how I can expand the functionality of the textbox to accept
larger amounts of data? I tried a richtextbox but it gives me the same
problem. Failing that, any ideas of a different control I could use
instead that comes with VB 2003?

I cannot use a listbox because I need the user to be able to highlight
sections of text or parts of text on one line and copy them to the
clipboard.

TIA
 
H

Herfried K. Wagner [MVP]

Hugh Janus said:
I have a form with a textbox control on it. I am using the textbox
control with multiline enabled to output the 'log' information for a
long process I am running. My problem is that it all works fine until
the limit of the size of text is reached for the text box. This causes
the textbox to stop update whilst the thread running the process
continues.

Any ideas how I can expand the functionality of the textbox to accept
larger amounts of data? I tried a richtextbox but it gives me the same
problem. Failing that, any ideas of a different control I could use
instead that comes with VB 2003?

Which amount of data are you writing to the control? Note that the machine
only has a limited memory. In addition to that, make sure you use
'Control.InvokeRequired', 'Control.Invoke'/'Control.BeginInvoke' to update
the control from another thread instead of accessing it directly, which will
cause problems because instance members of Windows Forms controls are not
safe for multithreading.
 
H

Hugh Janus

Which amount of data are you writing to the control? Note that the machine
only has a limited memory. In addition to that, make sure you use
'Control.InvokeRequired', 'Control.Invoke'/'Control.BeginInvoke' to update
the control from another thread instead of accessing it directly, which will
cause problems because instance members of Windows Forms controls are not
safe for multithreading.

It is not that much text, should not grow to more than 1 or 2 mb's of
pure text if it was saved as a text file in notepad, so memory should
not be a problem as far as I can tell. 2mb's is far greater than what
the Textbox or Richtextbox control can handle though. Any ideas?

p.s. I am using invoke to update the control already! thanks!
 
H

Hugh Janus

I am running Windows XP. The textbox just stops scrolling after a
while and no new information is added. I thought that the limit was
32k???
 
C

C-Services Holland b.v.

Hugh said:
It is not that much text, should not grow to more than 1 or 2 mb's of
pure text if it was saved as a text file in notepad, so memory should
not be a problem as far as I can tell. 2mb's is far greater than what
the Textbox or Richtextbox control can handle though. Any ideas?

p.s. I am using invoke to update the control already! thanks!

The textbox can easily handle that... unless you're running Win9x.
 
H

Herfried K. Wagner [MVP]

Hugh Janus said:
I am running Windows XP. The textbox just stops scrolling after a
while and no new information is added. I thought that the limit was
32k???

IIRC, 'AppendText' and 'SelectionStart' are still limited to 32 KB.
 
H

Hugh Janus

That is preciesely what I am using. AppendText. Upon further testing,
it seems that RichTextBox it works OK (I guess when I originally tested
one I had an error in my code). The problem with a RTB is that it does
not scroll automatically. So, I use the ScrollToCaret method but it is
not very reliable.

I guess I'll have to work out some 'cheat' for scrolling the RTB.
Thanks.
 
H

Herfried K. Wagner [MVP]

Hugh Janus said:
If the .Enabled is set to False on the RTB, how could I scroll it??
Or, is there an alternative way of stopping the user from interacting
with the RTB but still have it scrolling?

Maybe setting the control's 'ReadOnly' property to 'True' solves your
problem.
 
H

Hugh Janus

Herfried said:
Maybe setting the control's 'ReadOnly' property to 'True' solves your
problem.

I have the property set to True already. The problem is that you can
still place the cursor in the box. If i set enabled to false then it
does not scroll. Not to worry as I worked out another way, albeit a
bit shoddy. I have a timer that checks to see if the cursor has been
placed in the box. if it is, it takes it out.
 
C

C-Services Holland b.v.

Hugh said:
I have the property set to True already. The problem is that you can
still place the cursor in the box. If i set enabled to false then it
does not scroll. Not to worry as I worked out another way, albeit a
bit shoddy. I have a timer that checks to see if the cursor has been
placed in the box. if it is, it takes it out.

Instead of a timer, why don't you use the getfocus event? When the user
clicks in the box, it gets the focus, use that event to get rid of it again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top