记事本 查找

namespace FirstForm
{
    public partial class Find : Form
    {
        public Find()
        {
            InitializeComponent();
        }

        private WindowsFormsApplication6.Form1 fuform;
        public Find(string ss, WindowsFormsApplication6.Form1 fuchuangti)
        {
            InitializeComponent();
            textBox1.Text = ss;
            fuform = fuchuangti;
        }

        private void Find_Load(object sender, EventArgs e)
        {//放界面的控件初始值,另外还有成员变量的初始值
           
        }

        private int Index = -1;
        private void button1_Click(object sender, EventArgs e)
        {
            string finds = textBox1.Text;
            if (Index == -1)
            {
                fuform.textBox1.Select(fuform.textBox1.Text.IndexOf(finds), finds.Length);
                Index = fuform.textBox1.Text.IndexOf(finds) + 1;
            }
            else
            {
                if (Index + finds.Length < fuform.textBox1.Text.Length)
                {
                    fuform.textBox1.Select(fuform.textBox1.Text.IndexOf(finds, Index), finds.Length);
                    Index = fuform.textBox1.Text.IndexOf(finds, Index) + 1;
                }
            }
            this.fuform.Focus();
            this.fuform.textBox1.Focus();
        }
    }
}

  

posted on 2015-11-11 18:15  闫科达  阅读(202)  评论(0编辑  收藏  举报

导航