Solved

Does Tabcontrol Remove Tab Effect Selected Index?

Posted on 2011-03-22
3
396 Views
Last Modified: 2012-05-11
I would like to 'hide' a TabControl 'tab', but unsure how if effects the 'SelectedIndexChanged' event and a 'Switch' statement. I may confusing hide or visible with and actual Tab Remove.

tabControl1.TabPages.Remove(tabPage2);

Q. Will 'Remove' tab also remove its selectedIndex thus changing the switch & case below?

 switch (this.tabControl1.SelectedIndex)
 {
      case 0:
          do something...
      break;
     
      case 1:
          do another thing...
      break;
     
      case 2:
          do method...
      break;

      case 3:
          do another method...      
      break;
0
Comment
Question by:pointeman
  • 2
3 Comments
 
LVL 13

Accepted Solution

by:
Naman Goel earned 250 total points
ID: 35190233
yes it will basically we have a collection in TabControl for TabPages and Remove will remove the give Tab from that collection so that will definately affect TabIndex of each tab and in turn will affect SelectedIndex property

so instead of using SelectedIndex use SelectedTab property

0
 

Author Comment

by:pointeman
ID: 35192608
Very nice, been using index long time. SelectedTab is better.

switch (tabControl1.SelectedTab.Name)
               
- or -

switch (e.TabPage.Name)
0
 
LVL 13

Expert Comment

by:Naman Goel
ID: 35195646
yes... agreed. or you can assign Tag property with the required unique value for each TabPage and use it

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Launch Process with NOT as Administrator 15 67
Converting C# Objects into JSON file 7 41
Expando 4 36
VB.NET HttpWebRequest 12 34
Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now