<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 中的文本着色

        Selectively coloring text in RichTextBox(有选择地为 RichTextBox 中的文本着色)
        • <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# namespace alias - what#39;s the point?(C# 命名空间别名 - 有什么意义?)
                  Using Xpath With Default Namespace in C#(在 C# 中使用具有默认命名空间的 Xpath)
                  Generating an EDMX from a DB2 Database(从 DB2 数据库生成 EDMX)
                  IBM .NET Data Provider Connection String issue with Library List(库列表的 IBM .NET 数据提供程序连接字符串问题)
                  .NET DB2 OLEDB pre-requisites(.NET DB2 OLEDB 先决条件)
                  Referring to Code in IBM.Data.DB2 makes that Assembly Unavailable to the rest of my Solution(引用 IBM.Data.DB2 中的代码使该程序集对我的解决方案的其余部分不可用)

                      <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>
                            <tbody id='UqWtZ'></tbody>
                            <bdo id='UqWtZ'></bdo><ul id='UqWtZ'></ul>