This code is used to call a method defined in a MdiChild form which is currently active in an MDI application.
To test run this code, create a MDI windows forms application with two forms, one parent and another child.
Add a new method in the child form, Form2
public static void display() { MessageBox.Show("Child Form Method"); }
Create a delegate object in the class Form1 with matching signature as that of the method defined in Form2.
delegate void InvokeDisplay();
On click of a toolbutton in a ToolStrip or menuitem in a MenuStrip of Form1, add the following code to call the above method.
private void toolStripButton2_Click(object sender, EventArgs e) { this.ActiveMdiChild.Invoke(new InvokeDisplay(Form2.display));
}
|
No responses found. Be the first to respond and make money from revenue sharing program.
|