簡體   English   中英

RichTextBox->更改特定行的字體

[英]RichTextBox --> Change Font for specific line

我想更改特定行中的字體。 這是我的代碼...

string[] textBoxLines = richTextBox1.Lines;
foreach (string line in textBoxLines)
{
   if(line.StartsWith("-->"))
   {
   //here is my problem, how to can change the font in the spectific line...
   }
}
string[] textBoxLines = richTextBox1.Lines;
for (int i = 0; i < textBoxLines.Length; i++)
{
    string line = textBoxLines[i];
    if (line.StartsWith("-->"))
    {
        richTextBox1.SelectionStart = richTextBox1.GetFirstCharIndexFromLine(i);
        richTextBox1.SelectionLength = line.Length;
        richTextBox1.SelectionFont = yourFont;
    }
}
richTextBox1.SelectionLength = 0;//Unselect the selection

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM