资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

ComponentOneC1Editor中高亮查找文字

 ComponentOne C1Editor 是类似于 MS Word 和 MS FrontPage 文字编辑控件。用户可以使用 C1Editor 接口去搜索文字。所以,通常用户想实现搜索结果

专注于为中小企业提供网站设计、成都网站制作服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业泉州免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了上千家企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。

高亮的效果。这篇文章将通过代码介绍怎么使用 C1Editor 搜索并且高亮搜索结果。

参考代码:

            
            int length = this.c1Editor1.Text.Length;
            string searchString = this.textBox1.Text;
            int searchStringLen = searchString.Length;
            int result = 0;
            if (searchStringLen > 0)
            {
                for (int i = 0; i <= length; i++ )
                {
                    c1Editor1.SelectionStart = c1Editor1.SelectionStart + searchStringLen;
                    if ((i + searchStringLen) <= length)
                    {
                        //compare the text searched with the substring of the C1Editor
                        if (c1Editor1.Text.Substring(i, searchStringLen).ToLower() == searchString.ToLower())
                        {
                            c1Editor1.Select(i, searchStringLen);
                            //set the backcolor of each occurrence of the word in C1Editor
                            c1Editor1.Selection.ApplyStyle("background-color", "Red");
                            result = result + 1;
                        }
                    }
                }
            }

截图展示:

ComponentOne C1Editor 中高亮查找文字cdn.grapecity.com/p_w_upload.aspx?p_w_uploadid=2344">

Demo 下载

 很高兴能和大家分享 ComponentOne 的使用方法、讨论 ComponentOne 使用过程中遇到的问题。

葡萄城控件产品网站:http://www.gcpowertools.com.cn/ 
葡萄城技术支持论坛:http://gcdn.grapecity.com/

 


文章题目:ComponentOneC1Editor中高亮查找文字
浏览路径:http://cdkjz.cn/article/pescoh.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220