Appending Contents of two RichTextbox as a single RichText string

前端 未结 4 1722
难免孤独
难免孤独 2020-12-11 16:02

I want to append the contents of two rich text boxes in a Windows Forms .Net application; say: stringText = richtextbox1.Rtf + richtextbox2.Rtf; The strin

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-11 16:32

    well since I can't comment Pawel anwser, I must add that besides his code:

    RichTextBoxSource.Select(0,RichTextBoxSource.TextLength);
    RichTextBoxTarget.SelectedRtf = richTextBoxSource.SelectedRtf;
    

    you should add if you want the new text to be always on the top

    RichTextBoxTarget.Select(0,0);
    

    or if you want it to be always on the bottom

    RichTextBoxTarget.Select(RichTextBoxTarget.TextLength,0);
    

    So you also have control of the position like in Daniel answer, even if the target richtextbox is clickable.

提交回复
热议问题