0

Hi guys,

could somebody here tell me how to color the current text line in richTextBox Object, or where can I search for this feature???

Thanks

[EL-Prince]

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by privatevoid
0

Look at RichTextBox.Select() , see if the code below helps:

// The draw back to this is if a line wraps it will continue the 
// selection until a newline char is found.
int startIndex = myRtfEdit.GetFirstCharIndexOfCurrentLine();
int selectionLength = myRtfEdit.Text.IndexOf('\n', startIndex) - startIndex;
if(selectionLength > 0) myRtfEdit.Select(startIndex, selectionLength);
0

Hi,
Thanks about answering my question, but actually this NOT what I want.
What I want is highlight or coloring the current row of text in richTextBox object, not selecting text.

Thanks

[EL-Prince]

0

Actually it is key to what you want to do. To do most things in a RichTextBox you need to select the text you wish to alter so selecting that text can be the most complicated part.

with the above in mind consider the following:

myRtfEdit.SelectionColor = Color.Blue;
myRtfEdit.SelectionFont = myFont;
myRtfEdit.SelectionBackColor = Color.Gray;
myRtfEdit.DeselectAll();

Edited by privatevoid: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.