Windows Forms Topics include: windows forms, controls, components and designers

Go Back  Xtreme .NET Talk > .NET > Windows Forms > Hoe to Hide a TabPage in a TabControl (C#)


Reply
 
Thread Tools Display Modes
  #1  
Old 03-08-2003, 03:53 AM
Faisal Faisal is offline
Newcomer

Preferred language:
c#
 
Join Date: Mar 2003
Location: Pakistan
Posts: 1
Faisal is on a distinguished road
Default Hoe to Hide a TabPage in a TabControl



I have five tabpages on my tabcontrol and want to hide and show one of them on a button click
Reply With Quote
  #2  
Old 03-08-2003, 12:21 PM
divil's Avatar
divil divil is offline
Banned
 
Join Date: Nov 2002
Location: England
Posts: 2,746
divil is on a distinguished road
Default

You can't just hide and show tabs in a tabcontrol - it was never meant to operate that way. Nor can you disable individual tabs. The best you can do is to remove them all and add the ones you need, or to not show some in the first place.
Reply With Quote
  #3  
Old 04-03-2003, 11:56 AM
aewarnick's Avatar
aewarnick aewarnick is offline
Senior Contributor

Preferred language:
C#
 
Join Date: Jan 2003
Posts: 1,031
aewarnick is on a distinguished road
Default

You cannot Hide() the tab but you can Hide() the tab page itself. I did that with some of my tab pages if the password the user entered was incorrect.
__________________
C#
Reply With Quote
  #4  
Old 04-03-2003, 02:58 PM
Nerseus's Avatar
Nerseus Nerseus is offline
Danner

Preferred language:
C#
 
Join Date: Oct 2002
Location: Arizona, USA
Posts: 2,547
Nerseus is on a distinguished road
Default

Neither Hide() nor setting Visible=False will work with TabPages. You can remove them through the TabControl's Controls collection or the TabPages collection using the Remove method.

For example, use one of the two lines below (they do the same thing):
Code:
tabControl1.TabPages.Remove(tabPage2);
// OR
tabControl1.Controls.Remove(tabPage2);

Keep in mind that if you want to add the tabpages back in later, you have to add them in the order you want them. That may mean removing them all and adding them back in one at a time.

-Nerseus
__________________
"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Reply With Quote
  #5  
Old 04-07-2003, 05:28 AM
Ariez Ariez is offline
Centurion

Preferred language:
VB.NET
 
Join Date: Feb 2003
Posts: 164
Ariez is on a distinguished road
Default

Make a procedure like:
exposeContrls(Page as control)
to expose the controls dynamically with page.controls.add...etc..
then you can remove and add any tabpage and load its interface.
__________________
Auto-suggestion: "I have a life"
Uncontroled thinking: "So what the.."
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide tabpage kejpa Windows Forms 7 10-22-2004 07:51 AM
TabPage Problem Mr60s Windows Forms 1 03-10-2004 05:11 AM
Scrollbar access of a tabPage Steve Windows Forms 0 03-04-2004 11:12 AM
TabPage order change hog Windows Forms 2 03-18-2003 02:03 PM
TabPage w/in a TabPage mscott Windows Forms 2 02-06-2003 10:45 AM

Advertisement:







Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe