Never Ending Textbox

Phylum

Centurion
Joined
Jun 20, 2003
Messages
105
Location
Canada
I have a richtextbox on a form. A network stream keeps on providing it with text. Text is added to the bottom of the textbox and I keep the focus on the bottom line (default is to go back to the top of the textbox when text is added). What I need to do however is cut out text from the TOP of the textbox a certain amount of text once there is a certain amount of text in the control (you get memory overflows after a while).

A) How do I tell how many lines of text are in my richtextbox?
B) How do I trim lines of text from the top of the textbox?
 
"lines" is a vague term when you're talking about a multi-line textbox. There's a Lines property that you can access:

MessageBox.Show(TextBox1.Lines.GetLength(0))

However, this doesn't take into account lines that are wrapped, just lines with hard returns. It still might be usable for what you're doing though.
 
Back
Top