Link to home
Start Free TrialLog in
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??
Avatar of ororiole
ororiole
Flag of United States of America image

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.
Avatar of H-SC

ASKER

ororiole,

...I needed it to be in VB.  Can that be done?
ASKER CERTIFIED SOLUTION
Avatar of ororiole
ororiole
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of H-SC

ASKER

ororiole,

Perfect!!  That works great..