日期:2014-05-17 浏览次数:20772 次
find fd = new find();//子窗体名字,find int i =0; private void 查找ToolStripMenuItem_Click(object sender, EventArgs e) { fd.MyPing+=new find.PING(fd_MyPing);//关联委托 fd.Show(this); } void fd_MyPing(string str) //委托的处理事件 { int an = richTextBox1.Find(str, i, RichTextBoxFinds.MatchCase); if (an >0) { this.richTextBox1.Select(an, str.Length); i = an + str.Length; } else { MessageBox.Show("没有查找到相符的字符串"); } }
public delegate void PING(string str);//定义委托 public event PING MyPing; private void button1_Click(object sender, EventArgs e) { this.MyPing(this.textBox1.Text); }