-1

I have a MDIParent form named frmMain. It has a panel with 2 buttons let say btnChild1 and btnChild2. In the Click event of btnChild1 i have opened a frmChild1 and change the color of btnChild1. Now When frmChild1 will close I want the btnChild1.BackColor to be set to transparent. But I don't know in which event I have to code. Kindly Guide me?

Redaa
  • 1,540
  • 2
  • 17
  • 28
Polowing
  • 123
  • 1
  • 10

2 Answers2

0

You can archive this by handling the frmChild1 FormClosed event in your MDI Parent form like below

 private void button1_Click(object sender, EventArgs e)
 {
     Form2 childForm = new Form2();
     childForm.MdiParent = this;
     childForm.FormClosed += childForm_FormClosed;
     this.button1.BackColor = Color.Red;
     childForm.Show();
 }

 void childForm_FormClosed(object sender, FormClosedEventArgs e)
 {
     this.button1.BackColor = Color.Transparent;
 }
Vimal CK
  • 3,543
  • 1
  • 26
  • 47
0

You can do it this way..

1.Change the visibility of the button to Public in frmMain.

2.In the OnClose() event of frmChild1 do:

(this.MdiParent as frmMain).btnChild.BackColor="RequiredColor";

This violates the Object Oriented programming concept.

another way would be show your frmChild1 as dialog,So the control will be transferred back to frmMain only after frmChild gets closed and then afterwards change the button color to your requirement.

Dharani Kumar
  • 457
  • 2
  • 8