Rich Text Box how to highlight text block

后端 未结 3 572
庸人自扰
庸人自扰 2020-12-04 02:06

I need a certain portion of my text in RTB to be highlighted not in the sense of changing the font style/color, but in the sense of making a block selection with a particula

3条回答
  •  感动是毒
    2020-12-04 02:42

    Yes you can set the BackColor of a RichTextBox Selection using the RichTextBox.SelectionBackColor Property.

    int blockStart = 1; //arbitrary numbers to test
    int blockLength = 15;
    richTextBox1.SelectionStart = blockStart;
    richTextBox1.SelectionLength = blockLength;
    richTextBox1.SelectionBackColor = Color.Yellow;
    

提交回复
热议问题