Solved

Does Tabcontrol Remove Tab Effect Selected Index?

Posted on 2011-03-22
3
400 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

821 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