繁体   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