码迷,mamicode.com
首页 > 其他好文 > 详细

记事本 查找

时间:2015-11-11 19:22:27      阅读:321      评论:0      收藏:0      [点我收藏+]

标签:

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();
        }
    }
}

  

记事本 查找

标签:

原文地址:http://www.cnblogs.com/ROCKyou/p/4956757.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!