【问题标题】:RichTextBox --> Change Font for specific lineRichTextBox --> 更改特定行的字体
【发布时间】:2013-11-07 04:12:07
【问题描述】:

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

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...
   }
}

【问题讨论】:

    标签: c# fonts richtextbox lines


    【解决方案1】:
    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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-02-04
      • 2011-11-11
      • 2016-10-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多