J
jimcolli
I have a parent form with a menu button that has a handler.
I want to call this same handler when a button on a child form is
clicked.
I have this simplified code in the main form's Load handler.
public class frmMain
{
private System.Windows.Forms.Button btnClickMe;
private void frmMain_Load(object sender, System.EventArgs e)
{
// Following instance becomes visible when a menu
// button is clicked.
ChildForm frmMyChild = new ChildForm ( );
// ...
}
// ...
// (Windows Form Designer generated code)
// ...
private void btnClickMe_Click (object sender, System.EventArgs e)
{
// do some complicated stuff here
Console.WriteLine ("btnClickMe was clicked."
}
On the child form, I have another button which we'll call btnClickMeToo
with the usual click handler,
void btnClickMeToo_Click(object sender, System.EventArgs e)
{
}
I want this main form to "listen" to btnClickMeToo as well and
execute the code in its btnClickMe_Click handler when
it is clicked. The console message makes clear that
the event from the child form's button was handled.
I know I'm overlooking something fundamental here.
Anyone know how to do this?
I want to call this same handler when a button on a child form is
clicked.
I have this simplified code in the main form's Load handler.
public class frmMain
{
private System.Windows.Forms.Button btnClickMe;
private void frmMain_Load(object sender, System.EventArgs e)
{
// Following instance becomes visible when a menu
// button is clicked.
ChildForm frmMyChild = new ChildForm ( );
// ...
}
// ...
// (Windows Form Designer generated code)
// ...
private void btnClickMe_Click (object sender, System.EventArgs e)
{
// do some complicated stuff here
Console.WriteLine ("btnClickMe was clicked."
}
On the child form, I have another button which we'll call btnClickMeToo
with the usual click handler,
void btnClickMeToo_Click(object sender, System.EventArgs e)
{
}
I want this main form to "listen" to btnClickMeToo as well and
execute the code in its btnClickMe_Click handler when
it is clicked. The console message makes clear that
the event from the child form's button was handled.
I know I'm overlooking something fundamental here.
Anyone know how to do this?