zoukankan      html  css  js  c++  java
  • C# richTextBox 重下往上依次查找关键字

    2
    private void richTextBox1_SelectionChanged(object sender, EventArgs e)
    {
        pos = richTextBox1.SelectionStart;
    }
    private int pos = 0;
    private string str;
    private void btnFindNext_Click(object sender, EventArgs e)
    {
        str = textBox1.Text;
        pos = richTextBox1.Find(str, 0, pos, RichTextBoxFinds.Reverse);
        if (pos == -1)
           MessageBox.Show("无结果!");
    }


    int nEnd   控件文本中结束搜索的位置。让这个数值小于richTextBox1.TextLength就能实现搜索上一个的字符串
     




    public int Find(string str, int start, int end, RichTextBoxFinds options);
           
            //
            // 摘要:
            //     在对搜索应用特定选项的情况下,在 System.Windows.Forms.RichTextBox 控件文本中搜索控件内某个文本范围内的字符串。
            //
            // 参数:
            //   str:
            //     要在控件中定位的文本。
            //
            //   start:
            //
            //   end:
            //     控件文本中结束搜索的位置。此值必须等于 -1 或者大于或等于 start 参数。
            //
            //   options:
            //     System.Windows.Forms.RichTextBoxFinds 值的按位组合。
            //
            // 返回结果:
            //     控件内找到搜索文本的位置。
            //
            // 异常:
            //   System.ArgumentNullException:
            //     str 参数为 null。
            //
            //   System.ArgumentException:
            //     start 参数小于零。
            //
            //   System.ArgumentException:
            //     end 参数小于 start 参数。
  • 相关阅读:
    敌兵布阵(线段树)
    确定比赛名次(拓扑排序)
    Virtual Friends(并查集+map)
    A Bug's Life(向量偏移)
    Segment set(线段并查集)
    带权值得并查集
    Farm Irrigation(非常有意思的并查集)
    小希的迷宫
    Hadoop, Hadoop涉及到的一些常见概念(分布式与集群、HDFS、MapReduce等),Hadoop怎么用?
    Hadoop 的安装和使用(基于Linux~Ubuntu的虚拟机)
  • 原文地址:https://www.cnblogs.com/xe2011/p/3409645.html
Copyright © 2011-2022 走看看