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,
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,