我在做一个项目其中的一部分是。
如果富文本框的行号是奇数,我希望文本粗体,否则行号是偶数,我想写文本正常。我该怎么做?
输出必须如下所示:
线1(奇数) 第2行(偶数) 线3(奇数) 第4行(偶数)
我的英语不太好,对不起。
发布于 2018-03-11 03:03:55
使用RichTextBox.SelectionFont
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);https://stackoverflow.com/questions/49216058
复制相似问题