标签:
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