[英]Bold or normal text on the rich text box
我正在做一個項目,一部分是去。
如果富文本框的行號是奇數,則我希望文本加粗,否則行號是偶數,我要正常寫文本。 我怎樣才能做到這一點?
輸出必須是這樣的:
行號1(奇數)
第2行(偶數)
第3行(奇數)
行號4(偶數)
對不起,我的英語不太好。
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);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.