I am new to C # and I am using windows forms. I have Form1and Form2. In Form1I use the following code to show Form2:
Form2 frm2 = new Form2();
private void button1_Click(object sender, EventArgs e)
{
frm2.Show();
}
I want: I want to perform some actions when Form2displayed every time. I posted messageBoxin the event Form2Shown(for the test), but it only fires once and the next time I show Form2it never fires. I also tried to use it formLoad, but it only starts once and the next time I show Form2it never starts. I know that I can use frm2.ShowDialog () to show the displayed event every time, but for some reason I don't want to.
private void Form2_Shown(object sender, EventArgs e)
{
MessageBox.Show("Form2 is shown");
}
private void button_Hide_Form2_Click(object sender, EventArgs e)
{
Hide();
}
: - , , Form2? .