Solved

Does Tabcontrol Remove Tab Effect Selected Index?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

930 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

11 Experts available now in Live!

Get 1:1 Help Now