C# RichTextBox-->;更改特定行的字体

C# RichTextBox-->;更改特定行的字体,c#,fonts,richtextbox,lines,C#,Fonts,Richtextbox,Lines,我想更改特定行中的字体。这是我的密码 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=ric

我想更改特定行中的字体。这是我的密码

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;
对于(int i=0;i”)
{
richTextBox1.SelectionStart=richTextBox1.GetFirstCharIndexFromLine(i);
richTextBox1.SelectionLength=line.Length;
richTextBox1.SelectionFont=您的字体;
}
}
richTextBox1.SelectionLength=0//取消选择所选内容
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