I'm doing a project and part of is to.
if the line number of the rich text box is odd, I want the text to make bold, else the line number is even number I want write text normal. How can i do this?
Output must be like this:
line number 1 (odd)
line number 2 (even)
line number 3 (odd)
line number 4 (even)
My English is not so good, sorry.
int SelectionStart = richtextbox1.SelectionStart; //Start of bold text
int SelectionLenght = richtextbox1.SelectionLength; //End of bold text
// Set font of selected text
// You can use FontStyle.Bold | FontStyle.Italic to apply more than one style
richtextbox1.SelectionFont = new Font(richtextbox1.Font, FontStyle.Bold);
// Set cursor after selected text
richtextbox1.SelectionStart = richtextbox1.SelectionStart + richtextbox1.SelectionLength;
richtextbox1.SelectionLength = 0;
// Set font immediately after selection
richtextbox1.SelectionFont = richtextbox1.Font;
// Reselect previous text
richtexbox1.Select(SelectionStart, SelectionLength);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.