1

I want to know if it possible to use tabs (like Google Chrome or many others program) in VS Express 2010 to swap between forms without closing any window.

I know there is the tab control item in the tool box but as far as I know you need to create the tab content in the same form. I'm looking for a way to swap between form like if I put Buttons in the the top of each form (workers, customers, ext) that open the form I clicked and close the one I'm in but not change the main window.

Raidri
  • 17,258
  • 9
  • 62
  • 65
hen shalom
  • 127
  • 1
  • 1
  • 9
  • From what I see in this instruction video (https://www.youtube.com/watch?v=HBgSuUU5IMM) you can create all tabs in a separate form class, so not all in one form. – Marleen Schilt Dec 14 '15 at 11:55
  • use Mdi Forms and maximize each of them in every tab. – Inside Man Dec 14 '15 at 11:56
  • Using forms is pretty hokey, you'll have to carefully control location, size and Z-order. UserControls are the must more obvious alternative, simply place each on a tab. If necessary, you can very easily turn a Form into a user control with [this code](http://stackoverflow.com/a/7692113/17034). – Hans Passant Dec 14 '15 at 12:25

1 Answers1

0

You can use MDI parent method. If I understand rightly, this link will help you.

OR

You want it to be in the same window.

  1. Add this code this.IsMdiContainer = true; to main form.

  2. Create new form for every menu or button click.

    Form1 frm1;
    Form2 frm2;
    Form3 frm3;
    
  3. Create this function and call every button click for make to hide all form

    private void HideForms()
    {
        int frmCount = this.MdiChildren.Count<Form>();
        if (frmCount > 0)
        {
            for (int i = 0; i < frmCount; i++)
            {
                 this.MdiChildren[i].Hide();
            }
        }
    }
    
  4. After that button1, button2,... click event

    private void button1_clicked(...)
    {
        HideForms();
        if ((frm1 == null) || (frm1.IsDisposed))
            frm1 = new Form1();
        frm1.MdiParent = this;
        frm1.Dock = DockStyle.Fill;
        frm1.Show();
        frm1.BringToFront();
    }
    
Ian
  • 30,182
  • 19
  • 69
  • 107