c# RTB - paste plain text without colours/fonts?

前端 未结 10 1187
感动是毒
感动是毒 2021-02-06 07:42

I am using Rich Text object in my C# application. The only issue I am having is that when user pastes formated text from another app, it remains formated which I cannot have. Is

10条回答
  •  闹比i
    闹比i (楼主)
    2021-02-06 08:17

    Well the RichTextBox has a SelectionFont property so you can for instance do the following:

    Font courier;
    courier = new Font("Courier new", 10f, FontStyle.Regular);
    myRtb.SelectionFont = courier;
    myRtb.Font = courier; //So the typed text is also the same font
    

    If a text gets pasted, it will be automatically formatted.

提交回复
热议问题