accessing form controls from the class file RRS feed

  • Question

  • I am creating one c# project. In this project I have one mdi form and many child forms.
    All the child forms contains one panel named as panel1.
    Now when child form opens i use the following code in all child form

    all child forms' resize event contains the following line.

    panel1.Left = (this.ClientSize.Width - panel1.Width) / 2;
    panel1.Top = (this.ClientSize.Height - panel1.Height) / 2;
    so my question is if possible that the above code i write only once as in class file or any other way so i don't write this code in all the child forms' resize event.

    Tuesday, April 15, 2014 4:29 PM