|
-
May 14th, 2004, 08:32 PM
#1
Thread Starter
Junior Member
Removing lines from the top of a TextBox
I am writing a telnet client and must set a maximum of lines in the main RichTextBox. The RichTextBox.Lines property does not seem to contain any property or method to delete actual lines of text. Is there any way to remove entire lines from the top of the text box?
-
May 15th, 2004, 08:02 AM
#2
Addicted Member
You can use substring
Code:
// remove first line
string mystring = rtb.Text;
rtb.Text = mystring.Substring(mystring.IndexOf("\n",0) + 1,mystring.Length - mystring.IndexOf("\n",0) - 1);
-
May 15th, 2004, 09:32 AM
#3
Thread Starter
Junior Member
Well, I have been applying color formatting to the RichTextBox. I have tried what you say before and other things like it but, when I do it this way, since I'm refilling the entire box, I lose all formatting. I must specifically find a way to remove the original lines from the top without refilling the box.
-
May 15th, 2004, 12:31 PM
#4
Addicted Member
hm try this
Code:
rtb.SelectionStart = 0;
rtb.SelectionLength = rtb.Text.IndexOf("\n",0) + 1;
rtb.SelectedText = "";
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|