日期:2014-05-17 浏览次数:20931 次
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2();
f2.ShowLog += new EventHandler<LogEventArgs>(f2_ShowLog);
f2.Show();
}
void f2_ShowLog(object sender, LogEventArgs e)
{
textBox1.Text = e.Text;
}
}
}
namespace WindowsFormsApplication1
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
OnShowLog(new LogEventArgs("log log log log log"));
}
private void OnShowLog(LogEventArgs e)
{
if (ShowLog != null) ShowLog(this, e);
}
public event EventHandler<LogEventArgs> ShowLog;
}
public class LogEventArgs