0
votes

I'm implementing a step-by-step alignment.

Getting current line in rtb1. and to show in rtb2.

i want

first line 111111111111111

second line 222222222222222

thrid line 3333333333333333

but

first line 1111111111111111 second line 22222222222222

thrid line 3333333333333333

fouth line 4444444444444444

i don't know my error... this.. some of my code.. line method get current line, so, richTextLineIndex is line's start Index.

    private int GetTextPositionAndLength(int position, int lineIndex, out int length)
    {
        int richTextLineIndex = GetFirstCharIndexFromLine();

        TextPointer textpointer = rtb1.CaretPosition.DocumentStart;
        string line = Lines(count);

        if (position == 0)
        {
            length = GetTextLength(0, lineIndex);
            rtb2.AppendText(line);
            return richTextLineIndex;
        }
        rtb2.AppendText(line);

        return index + richTextLineIndex;
    }
    private string Lines(int LineIndex, string Default = "null")
    {
        TextPointer start= rtb1.CaretPosition.DocumentStart.GetPositionAtOffset(startPoint);
        TextPointer end = rtb1.CaretPosition;
        var range = new TextRange(start, end);
        line = range.Text;
        startPoint += line.Length;
        return line;
    }
2

2 Answers

1
votes

Have you tried

  rtb2.AppendText(line+"\r");
0
votes

rtb2.Text = rtb2.Text + Environment.NewLine + line;