• 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 参数。
  • 相关阅读:
    Python基础---线程
    virtualenv和virtualenvwrapper的安装和使用
    微信公众号实现简易的物联网控制(二)
    PyQt5之SQLite数据库操作(1)
    PyQt5无边框后窗口的移动方法
    PyQt5显示GIF图片
    Python显示进度条的方法
    WinSCP默认使用root用户登录的方法
    微信公众号实现简易的物联网控制(一)
    Arduino语音天气预报(三)
  • 原文地址:https://www.cnblogs.com/xe2011/p/3409645.html
Copyright © 2020-2023  润新知