tags:

views:

753

answers:

4

How do i get rid of the body in my tabControl? and how do i add and remove tabpages? I need to add/remove tabpages in code but hide the body in code or in the editor. I tried making the tabControl hight <20 but no matter what it has a line showing how wide it is.

+1  A: 

What do you mean by "hide the body"? If you mean the "page" part of the tab, it's not really a tab page any more if you can only see the labels. What are you trying to accomplish? It may well be that a tab control isn't the best approach.

Jon Skeet
I have a search and i would like to do multiple at once. I have one copy of controls that will hold the display info, all i need is a way for the user to switch between results he would like. Tab seems like a logic choose, except i dont need its body.
acidzombie24
Sounds non-idiomatic to me. If I see tabs, I expect them to switch between tab pages. If it didn't actually change anything, I'd be surprised. Have you tried radio buttons?
Jon Skeet
Thats a good idea. However it would seem awkward for radios to appear when creating a search. It wont feel like switching between result/page. But i know it would work.
acidzombie24
+1  A: 

You can create new tab pages in code and add them to the TabControl's Controls collection:

private System.Windows.Forms.TabPage tabPage1;        
this.tabPage1 = new System.Windows.Forms.TabPage();           
this.tabControl1.Controls.Add(this.tabPage1);

You can hide the tab control from code with this:

tabControl1.Hide();
Slidell4life
Part one of my question thanks :)To bad i cant set multiple answer.
acidzombie24
+2  A: 

As far as I know, there's no built-in control for a row of tabs without pages for each tab.

You could just cover the body with a Panel. If you adjust the size of the panel carefully, it should look ok.

Blorgbeard
Perfect, it acted like i hoped :D
acidzombie24
+1  A: 

To hide the tabpage from the user you just remove it from the tabControl.TabPages collection like so: tabControl1.TabPages.Remove(tabPage1);