BringToFront()方法触发哪些事件? [英] which events does BringToFront() method trigger?
问题描述
我有两个Form1和Form2,每次在Form1中调用Form2.BringToFront()时,我都想在Form2中做一些事情.
I have two Forms, Form1 and Form2 and I want to do something in Form2 whenever I call Form2.BringToFront() in Form1.
class Form1 : Form
{
button1_MouseClick()
{
Form2.BringToFront();
// trigger an event an do something in Form2
}
}
class Form2 : Form
{
UnknownEvent_EventHandler()
{
//do something
}
}
但是BringToFrontMethod的文档没有说明此方法触发哪些事件.
But Documentation on BringToFrontMethod doesn't say which events does this method trigger.
注意,我不想在Form2上创建一个公共方法并调用它.
推荐答案
它不会直接触发我所知道的一个,但是由于其Activation(focus)被更改,Form.Activated Event将被触发.您可以找到代码文档
Well it doesn't fire one directly that I know of, but as a result of its Activation(focus) being changed the Form.Activated Event will fire. You can find the code documentation here. Here is a little sample code:
private void Form1_Activated(object sender, System.EventArgs e)
{
//What do you want to happen?
}
如果这有帮助,请确保将其标记为答案.
If this helps you be sure to mark it as the answer.
这篇关于BringToFront()方法触发哪些事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!