Solved

Show Hide Tab Pages in Tab Control

Posted on 2015-01-29
12
149 Views
Last Modified: 2015-02-26
Hi All,

I am developing a windows application in which i am using the tab control in one winform. I have multiple tab pages in that tab control. I want to show/hide the particular tab pages programatically. How can i achieve this?

Please help me to solve this issue.

Regards
0
Comment
Question by:Jatin Nahar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +3
12 Comments
 
LVL 50

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 40579262
Hi,

You cannot hide them, you have to remove and add them

tabControl1.TabPages.RemoveByKey("tabPage1");

pls refer to
https://msdn.microsoft.com/en-us/library/aa984280(v=vs.71).aspx

Regards
0
 

Author Comment

by:Jatin Nahar
ID: 40579406
Hi Rgonzo,

Thank you for your response.

I know this but i don't want to remove it, i just want to show/hide them based on the conditions through coding.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 40579453
You have to remove it like it was shown before. You can always add it back
0
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
LVL 70

Expert Comment

by:Éric Moreau
ID: 40579454
0
 
LVL 16

Expert Comment

by:DansDadUK
ID: 40579484
Perhaps just set the TabControl state to Enabled = false.

Then your code can control which tab page is displayed.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 40579602
DansDadUK, you have never used the TabControl right? Otherwise, you would know that there is no Enabled property on tab pages!
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 40579960
As stated in the above posts the only way to show and hide a TabPage is to actually add or remove it from the TabPage collection.
0
 
LVL 8

Expert Comment

by:Naitik Gamit
ID: 40581193
0
 
LVL 16

Expert Comment

by:DansDadUK
ID: 40581383
... you have never used the TabControl right? ...
Eric - you are quite correct - I've never used TabControl within a Windows Forms project.

I was a programmer and/or debugger of other people's code (in PLAN, COBOL, SCL, S3, C, C++, JScript, etc) over a period of nearly 40 years before I retired nearly 6 years ago.
Since then I've taught myself (the rudiments of) C#, using Windows Presentation Foundation (WPF) within Visual Studio, and in that environment, the TabControl control has a Focusable toggle, which (if set to false) means that the user cannot directly select individual tabs within the control, but they can be selected programmatically).

I (perhaps naively) assumed that Windows Forms (being the older technology) would have something similar, and wrote my earlier comment without properly checking the documentation.

Sorry!
0
 
LVL 16

Expert Comment

by:DansDadUK
ID: 40581585
What am I not understanding about enabling/disabling TabControl within a Windows Forms project?:
Sample TabControl within C
Or are we talking at cross purposes?
Please explain.

... or perhaps the clue is in your comment:

>> ... there is no Enabled property on tab pages ...

I'm referring to the property on the TabControl, not on individual TabPage items.
Perhaps (I haven't checked 'cos I don't use Windows Forms) disabling the TabControl item disables the tab pages as well, so even if one of them is programmatically selected, the user can't interact with it?
Yes - the tab pages are also disabled if the tabcontrol is disabled.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 40581707
This setting disable the complete tabcontrol (all the pages and their contents). It is not what the asker wants!
0
 

Author Closing Comment

by:Jatin Nahar
ID: 40634827
good solution
0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

697 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question