Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

Posted

"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.

Here's what I'm up to.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...