How to limit TextBox buffer size ?

G

Guest

Hi,
my small app listens on a channel and then writes all incoming data
(formatted in text strings) to a multiline textbox. Now I am trying to set
limit on this textbox buffer (i.e. max number of lines in textbox). It should
work similarly to screen buffer size in DosBox, once the limit is reached and
new string is appended to the end, the very first string should automatically
be removed. I expected something like TextBox.Lines.Remove(..), but
apparently, there is no similar method built-in in textbox. Then I tried to
manipulate string[] lines property of the TextBox, but it does not seem to
work. Neither works removing substring from Text property. The only working
workaround I found is to copy the whole array of lines to another array, then
to clear Text property, and finaly to add the whole bunch of lines back to
textbox. But this is very ineffective and expensive method. So I am wondering
if I am perhaps overlooking something quite obvious. From low level point of
view such task is kind of trivial, just removing first item from either
linked list, or from array of pointers, and refreshing... but I am not able
to figure out how to do it with .NET framework.

Thanks,
 
G

Guest

ALexander,

thanks, but that was the first one I tested, and it simply does not allow to
write chars in case the limit is reached. What I am after is kind of rolling
function - in case buffer is full, first line(s) are automatically discarded
from the top and user can add/append to the bottom.


Alexander Vasilevsky said:
Please try MaxLength property

--
http://www.alvas.net - Audio tools for C# and VB.Net developers


"Rostislav" <[email protected]> ÓÃÃÂÃÉÌ/ÓÃÃÂÃÉÌà ×
ÃŽÃ×ÃÓÔÑÈ ÓÌÅÄÕÀÃÃ…Ã…:
Hi,
my small app listens on a channel and then writes all incoming data
(formatted in text strings) to a multiline textbox. Now I am trying to set
limit on this textbox buffer (i.e. max number of lines in textbox). It
should
work similarly to screen buffer size in DosBox, once the limit is reached
and
new string is appended to the end, the very first string should
automatically
be removed. I expected something like TextBox.Lines.Remove(..), but
apparently, there is no similar method built-in in textbox. Then I tried
to
manipulate string[] lines property of the TextBox, but it does not seem to
work. Neither works removing substring from Text property. The only
working
workaround I found is to copy the whole array of lines to another array,
then
to clear Text property, and finaly to add the whole bunch of lines back to
textbox. But this is very ineffective and expensive method. So I am
wondering
if I am perhaps overlooking something quite obvious. From low level point
of
view such task is kind of trivial, just removing first item from either
linked list, or from array of pointers, and refreshing... but I am not
able
to figure out how to do it with .NET framework.

Thanks,
 

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