Delegates in C# -
Delegates are used to Call non-member function of the Class/ Form. (functions of other class/ Form)
like e.g.
If we want to call load event of Form1 =>Form1_Load() event On closing of Form2 => Form2_Closing().
Coding =>
1. In Form1 Coding
public delegate voidForm1FormLoadHandler();
public eventForm1FormLoadHandlerForm1FormLoad;
public void OnFrm_BudgetDetailsFormLoad()
{
object s = null;
EventArgs e = null;
Form1_Load(s, e);
}
In Form2 Coding
private void Form2_FormClosing(object sender, FormClosingEventArgs e)
{
Form1 frm = (Form1)this.frm;
Form1.Form1LoadHandler f = null;
f += new Form1.Form1LoadHandler(frm.OnForm1Load);
frm.OnForm1Load();
}
Delegates are used to Call non-member function of the Class/ Form. (functions of other class/ Form)
like e.g.
If we want to call load event of Form1 =>Form1_Load() event On closing of Form2 => Form2_Closing().
Coding =>
1. In Form1 Coding
public delegate voidForm1FormLoadHandler();
public eventForm1FormLoadHandlerForm1FormLoad;
public void OnFrm_BudgetDetailsFormLoad()
{
object s = null;
EventArgs e = null;
Form1_Load(s, e);
}
In Form2 Coding
private void Form2_FormClosing(object sender, FormClosingEventArgs e)
{
Form1 frm = (Form1)this.frm;
Form1.Form1LoadHandler f = null;
f += new Form1.Form1LoadHandler(frm.OnForm1Load);
frm.OnForm1Load();
}