Avatar of H-SC
H-SCFlag for United States of America asked on

Display everything below a certain line in RichTextBox1 In RichTextBox2

I have a form that has 2 RichTextBoxes on it.  I would like everything below line 47 in RTB1 to be diaplayed in RTB2.  Can this be done??
.NET Programming

Avatar of undefined
Last Comment

8/22/2022 - Mon

Sure, how about this? If by 'below' you mean as displayed (48..n) is 'below' 47
       private void Form1_Load(object sender, EventArgs e)
            string [] lines = new string[richTextBox1.Lines.Length];

            if (richTextBox1.Lines.Length > 47)
                Array.Copy(richTextBox1.Lines, 48, lines, 0, richTextBox1.Lines.Length - 48);
                richTextBox2.Lines = lines;
                lines = new string[48];

                Array.Copy(richTextBox1.Lines, lines,48 );
                richTextBox1.Lines = lines;
If you mean below is lines 0-46 then just change the logic to get the lines <47. OR, just swap the two arrays after running this code.


...I needed it to be in VB.  Can that be done?

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question


Perfect!!  That works great..
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck