views:

387

answers:

1

Hi I want to select a particular line of text and highlight it with a Blue Color and i want the forecolor of that text to be white. I tried

 this.Select(start, length);
 this.SelectionBackColor = Color.Blue;
 this.SelectionColor = Color.White;

but it doesn't work. What is wrong? I want to simulate the effect we get when we select some text through the mouse, where it's backcolor gets light blue and text inside gets white. I can get that by just doing

 this.Select(start, length);

but then as soon as it loses focus, the selection vanishes, i want it permanent.

A: 

Try doing something like this:

        this.richTextBox1.SelectionStart = start;
        this.richTextBox1.SelectionLength = length;
        this.richTextBox1.SelectionColor = Color.White;
        this.richTextBox1.SelectionBackColor = Color.Blue;
BFree