Results 1 to 4 of 4

Thread: Removing lines from the top of a TextBox

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2002
    Posts
    30

    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?

  2. #2
    Addicted Member
    Join Date
    Jun 2003
    Location
    Birmingham, AL
    Posts
    188
    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);

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2002
    Posts
    30

    Unhappy

    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.

  4. #4
    Addicted Member
    Join Date
    Jun 2003
    Location
    Birmingham, AL
    Posts
    188
    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
  •  



Click Here to Expand Forum to Full Width