Inside Form1.cs file Declare a Delegate like
public delegate void MyDelegate(); // it should be defined outside Form1
then in side Form1
--------------------------------------------------
private void doTest()
{
MessageBox.Show("Hi from Form1");
}
private void Form1_Load(object sender, System.EventArgs e)
{
Form2 frmTest = new Form2();
frmTest.MyDelegate = new MyDelegate(doTest);
frmTest.Show();
}
Inside Form2
-----------------------------------------------------
private MyDelegate testdelegate;
public MyDelegate MyDelegate
{
get
{
return testdelegate;
}
set
{
testdelegate = value;
}
}
private void button1_Click(object sender, System.EventArgs e)
{
testdelegate();
}
HTH
Shishir Kumar Mishra
Manhattan Associates