Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Does Tabcontrol Remove Tab Effect Selected Index?

Posted on 2011-03-22
3
Medium Priority
?
404 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 1000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
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.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

782 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