Windows Develop Bookmark and Share   
 index > Windows Forms General > Invoke Activated Child Method
 

Invoke Activated Child Method

Hi guys,

I need to know how to activate the Active child method.

For example, I create 2 newchild A and B (both the same form), I want to get Form A and print.

How do I do that.

Thanks.

Noobie and Newbie  Tuesday, May 22, 2007 10:59 AM
Here's a simple example:

public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void toolStripButton1_Click(object sender, EventArgs e) {
Form2 f2 = new Form2();
f2.MdiParent = this;
f2.Show();
}
private void toolStripButton2_Click(object sender, EventArgs e) {
Form2 f2 = this.ActiveMdiChild as Form2;
if (f2 != null) f2.DoSomething();
}
}

nobugz  Tuesday, May 22, 2007 3:22 PM
Could you explain your problem clearly
E.Veera Raghavendra  Tuesday, May 22, 2007 11:06 AM
Here's a simple example:

public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void toolStripButton1_Click(object sender, EventArgs e) {
Form2 f2 = new Form2();
f2.MdiParent = this;
f2.Show();
}
private void toolStripButton2_Click(object sender, EventArgs e) {
Form2 f2 = this.ActiveMdiChild as Form2;
if (f2 != null) f2.DoSomething();
}
}

nobugz  Tuesday, May 22, 2007 3:22 PM

private void Print_Click(object sender, EventArgs e)

{

Product product = this.ActivateMdiChild as Product;

if (product != null)

{

product.Print();

}

}

got error

Cannot convert type 'method group' to 'Ippcm Product' via a built-in conversion.

Product is my application Form(child).

Thanks nobugz

Noobie and Newbie  Thursday, May 24, 2007 9:09 AM
Active, not Activate.
nobugz  Thursday, May 24, 2007 10:13 AM
Thanks, nobugz. Stupid of me to see things wrong. Smile
Noobie and Newbie  Friday, May 25, 2007 2:03 AM

You can use google to search for other answers

Custom Search

More Threads

• Thread Message Queue
• Regarding SendMessage() question posted before...
• Is it possible to create a switch-case statement with button-click events?
• how can i get name of the parent class
• How to dynamically set DefaultValue for PropertyGrid?
• Editing a custom control - DLL
• Save File Dialog. (I have code, just need a little help fixing)
• Strange behavior with tooltips
• Strange Toolbar Error
• Need to change TextBox border color