Hi Schneider,
Thank you for your reply!
In your example, I consider this behavior would happen only in the case
that you set the TopMost property of Form B to true and after you show Form
C, you activate Form A and then activate Form C again.
Is there a way to stop Form C from causing the activation of Form A?
It's Windows that tracks and determines which form would be activated next.
In the above case, to prevent the activation of Form A after Form C is
closed, a workaround is to set Form A as the owner of Form B and set Form B
as the owner of Form C. Handle the Activated event of Form A and Form B and
activate its owned form in the event handler.
The following is the code in Form A.
public partial class FormA : Form
{
public FormA()
{
InitializeComponent();
this.Activated += new EventHandler(FormA_Activated);
}
void FormA_Activated(object sender, EventArgs e)
{
if (this.OwnedForms.Length > 0)
{
this.OwnedForms[0].Activate();
}
}
private void button1_Click(object sender, EventArgs e)
{
FormB frm = new FormB();
frm.Owner = this;
frm.Show();
}
}
Hope this is what you want.
If you have any question, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
This posting is provided "AS IS" with no warranties, and confers no rights.