zoukankan      html  css  js  c++  java
  • WinForm richtextbox 关键字变红色


            private void HilightRichText(RichTextBox control, string hilightString)
            {
                int nSelectStart = control.SelectionStart;  
                int nSelectLength = control.SelectionLength;
                int nIndex = 0;
                while (nIndex < control.Text.Length)
                {
                    nIndex = control.Find(hilightString, nIndex, RichTextBoxFinds.WholeWord); //整个文档查找
                    if (nIndex < 0)
                    {
                        break;                     
                    }
                    control.Select(nIndex, hilightString.Length);      //选择文本
                    control.SelectionColor = Color.Red;
                    nIndex += hilightString.Length;
                }
                control.Select(nSelectStart, nSelectLength);
            }

  • 相关阅读:
    Tomcat虚拟目录的映射方式
    Linux常用命令
    java断点调试
    破解MyEclipse
    JS判断浏览器
    css3 box-sizing详解。
    this-使用call . apply
    this-内部函数
    this-对象方法调用
    this-纯函数
  • 原文地址:https://www.cnblogs.com/c-cccc/p/6189162.html
Copyright © 2011-2022 走看看