Using multiple Forms inside panels in c#

155 views Asked by At

I am working on a program which contains many forms and tabs so I created a top panel to contain the tabs and create a container panal to contain forms because I want every opened form be inside the main form, it works but small problems faced me and I will attach the code that I used.

  1. Forms open in top left corner while I need them opened in the panal center I tried form.StartPosition = FormStartPosition.CenterScreen; not working

  2. When I open form 1 and form 2 , form 2 became in the front and form 1 back and you cann't see form 1 unless you drag form 2 to another place I tried : form.BringToFront(); and form.Activate(); not working.

  3. Usually when need to move cross forms you can click in every place in second form and its became in front in me situation I can not unless I click on the top bar for the form which is looks gray unlike the common form top bar while black dot is in VS designing and Blue dot is after running the form inside the panal here

Used code to contain the forms inside panals :

 private void showFormsInPanal(object Form)
        {  
            Form form = Form as Form;
            form.TopLevel = false;
            this.containerPanal.Controls.Add(form);
            form.StartPosition = FormStartPosition.CenterScreen;
            form.Show(); 
        }

private void branchBtn_Click(object sender, EventArgs e)
        { 
           showFormsInPanal(new Branches());
        }
0

There are 0 answers