Hisham Safwat
Hisham Safwat

Reputation: 23

how to doc more than one tabcontrol in a panel in c#?

i have a small solution including big amount of data in #temp table and then make queries to produce around 16 reports

i have four tab controls each one include 5 reports

i use tabcontorl.hide () to control these four categories of reports for user usablity

the problem is i want to dock each tab control so it takes the size of the form

i tried to make a panel and put the tabcontrol inside and it works but for one tabcontrol when i put another on , just one appear and tried bringtofront() but no way.

i tried to create multiple panels but i can't put them over each other

any solution for this

Upvotes: 0

Views: 29

Answers (1)

Caius Jard
Caius Jard

Reputation: 74605

Put 4 tab controls on your form, in design view, so they're laid out nicely and you can see them each taking up a quarter of the form (so you can still edit them):

1 2
3 4

Then in your form constructor, after the call to InitializeComponent, set each of the tabcontrols dock to Fill and Visible to false

public Form1(){
  InitializeComponent();
  tabControl1.Dock = tabControl2.Dock = tabControl3.Dock = tabControl4.Dock = DockStyle.Fill;
  tabControl1.Visible = tabControl2.Visible = tabControl3.Visible = tabControl4.Visible = false;

}

Then switch between them by making them all Visible = false, and then only the one you want to Visible = true:

public void ShowTab2_Click(object sender, ClickEventArgs e){
    tabControl1.Visible = tabControl2.Visible = tabControl3.Visible = tabControl4.Visible = false;
    tabControl2.Visible = true;
}

Or however it is you're managing the user switching tab controls

Upvotes: 1

Related Questions