<tfoot id='AyvQY'></tfoot>
  • <i id='AyvQY'><tr id='AyvQY'><dt id='AyvQY'><q id='AyvQY'><span id='AyvQY'><b id='AyvQY'><form id='AyvQY'><ins id='AyvQY'></ins><ul id='AyvQY'></ul><sub id='AyvQY'></sub></form><legend id='AyvQY'></legend><bdo id='AyvQY'><pre id='AyvQY'><center id='AyvQY'></center></pre></bdo></b><th id='AyvQY'></th></span></q></dt></tr></i><div id='AyvQY'><tfoot id='AyvQY'></tfoot><dl id='AyvQY'><fieldset id='AyvQY'></fieldset></dl></div>
    <legend id='AyvQY'><style id='AyvQY'><dir id='AyvQY'><q id='AyvQY'></q></dir></style></legend>

      1. <small id='AyvQY'></small><noframes id='AyvQY'>

        • <bdo id='AyvQY'></bdo><ul id='AyvQY'></ul>

        有选择地为 RichTextBox 中的文本着色

        时间:2023-09-17
        • <bdo id='zK7sw'></bdo><ul id='zK7sw'></ul>
            <tfoot id='zK7sw'></tfoot>
          • <i id='zK7sw'><tr id='zK7sw'><dt id='zK7sw'><q id='zK7sw'><span id='zK7sw'><b id='zK7sw'><form id='zK7sw'><ins id='zK7sw'></ins><ul id='zK7sw'></ul><sub id='zK7sw'></sub></form><legend id='zK7sw'></legend><bdo id='zK7sw'><pre id='zK7sw'><center id='zK7sw'></center></pre></bdo></b><th id='zK7sw'></th></span></q></dt></tr></i><div id='zK7sw'><tfoot id='zK7sw'></tfoot><dl id='zK7sw'><fieldset id='zK7sw'></fieldset></dl></div>

              <small id='zK7sw'></small><noframes id='zK7sw'>

                    <tbody id='zK7sw'></tbody>

                1. <legend id='zK7sw'><style id='zK7sw'><dir id='zK7sw'><q id='zK7sw'></q></dir></style></legend>
                  本文介绍了有选择地为 RichTextBox 中的文本着色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如何在 RichTextBox 中每次遇到字母A"时都画成红色?

                  How can I paint in red every time I meet the letter "A" in RichTextBox?

                  推荐答案

                  试试这个:

                  static void HighlightPhrase(RichTextBox box, string phrase, Color color) {
                    int pos = box.SelectionStart;
                    string s = box.Text;
                    for (int ix = 0; ; ) {
                      int jx = s.IndexOf(phrase, ix, StringComparison.CurrentCultureIgnoreCase);
                      if (jx < 0) break;
                      box.SelectionStart = jx;
                      box.SelectionLength = phrase.Length;
                      box.SelectionColor = color;
                      ix = jx + 1;
                    }
                    box.SelectionStart = pos;
                    box.SelectionLength = 0;
                  }
                  

                  ...

                  private void button1_Click(object sender, EventArgs e) {
                    richTextBox1.Text = "Aardvarks are strange animals";
                    HighlightPhrase(richTextBox1, "a", Color.Red);
                  }
                  

                  这篇关于有选择地为 RichTextBox 中的文本着色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:将 C# 字符串解析为 DateTime 下一篇:设置默认日期时间格式 c#

                  相关文章

                      <small id='UqWtZ'></small><noframes id='UqWtZ'>

                      <legend id='UqWtZ'><style id='UqWtZ'><dir id='UqWtZ'><q id='UqWtZ'></q></dir></style></legend>

                    1. <tfoot id='UqWtZ'></tfoot>
                      <i id='UqWtZ'><tr id='UqWtZ'><dt id='UqWtZ'><q id='UqWtZ'><span id='UqWtZ'><b id='UqWtZ'><form id='UqWtZ'><ins id='UqWtZ'></ins><ul id='UqWtZ'></ul><sub id='UqWtZ'></sub></form><legend id='UqWtZ'></legend><bdo id='UqWtZ'><pre id='UqWtZ'><center id='UqWtZ'></center></pre></bdo></b><th id='UqWtZ'></th></span></q></dt></tr></i><div id='UqWtZ'><tfoot id='UqWtZ'></tfoot><dl id='UqWtZ'><fieldset id='UqWtZ'></fieldset></dl></div>
                      • <bdo id='UqWtZ'></bdo><ul id='UqWtZ'></ul>