索引值是跟顺序查找时一样,从文本开头开始的么?
怎么每次查找都是只能找到文本最后那个符合的字符串?
谢谢啦。

解决方案 »

  1.   

    使用public int Find(string str, int start, int end, RichTextBoxFinds options)
      

  2.   

    但是只找到了第一个出现位置,更改star的位置结果还是一样。   
      

  3.   

    private void button1_Click(object sender, EventArgs e)
            {
               
                this.richTextBox1.SelectionColor = this.richTextBox1.ForeColor;
                string str = "b";
                if (lastIndex == -1)
                {
                    lastIndex = this.richTextBox1.Text.Length - 1;
                }
                lastIndex = this.richTextBox1.Find(str, 0, lastIndex, RichTextBoxFinds.Reverse);
                if (lastIndex != -1)
                {
                    this.richTextBox1.SelectionStart = lastIndex;
                    this.richTextBox1.SelectionLength = str.Length;
                }
                this.richTextBox1.SelectionColor = Color.Red;
            }
      

  4.   

    private void button1_Click(object sender, EventArgs e)
            {
               
                this.richTextBox1.SelectionColor = this.richTextBox1.ForeColor;
                string str = "b";
                if (lastIndex + 1 == this.richTextBox1.Text.Length)
                {
                    lastIndex = -1;
                }
                lastIndex = this.richTextBox1.Find(str, lastIndex + 1, this.richTextBox1.Text.Length - 1, RichTextBoxFinds.None);
                if (lastIndex != -1)
                {
                    this.richTextBox1.SelectionStart = lastIndex;
                    this.richTextBox1.SelectionLength = str.Length;
                }
                this.richTextBox1.SelectionColor = Color.Red;
            }
    下次要记得放分