help in adding text from richtextbox 1 with richtextbox2 C #

1
Hello, I would like to know how I do it, so that when I type in richtextbox1 the text will appear in richtextbox2 , just like if it was a line counter, every time you enter enter, only with a number itself, type a1, a9, b, c4, c5 ......
see the image here

    
asked by anonymous 08.02.2016 / 21:49

1 answer

1

Does the numbering you say have a logical sequence?

I suggest putting an event in the keypress of your richtextbox1

I transferred the text of rchtb1 to an array (Split breaking lines at each Enter) for each line I wrote in rchtb2 and broke the line.

private void richTextBox1_KeyPress(object sender, KeyPressEventArgs e)
{
    if (e.KeyChar == 13)
    {
        richTextBox2.Clear();
        string texto = richTextBox1.Text;
        string[] linhas = texto.Split('\n');
        foreach (string linha in linhas)
        {
            richTextBox2.AppendText(linha + Environment.NewLine);
        }
    }
}

If you want to define this sequence, which I did not quite understand, you should put before the variable linha in richTextBox2.AppendText .

    
09.02.2016 / 02:30