How to make a tabpages visible

Posted on 2005-02-28
Medium Priority
Last Modified: 2008-02-01
Hi I have an issue. I have removed certain tabpages for a tabcontrol as follows
   'Display Default Tab

however if i want to redisplay certain tabs using the syntax below it does not work. Any Ideas?

Question by:anwarmir
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
  • 2
LVL 12

Expert Comment

ID: 13418512
Ok, can't really give a better answer than this without seeing more of your code, like where TabCheck is defined... but this simple code adds a new tab which is visible... so you can modify it for your own purposes and see if that works:

        Dim x As New TabPage()
        x.Text = "Hello"
        x.Visible = True

If this isn't working, post some more of your code up including the declaration of TabCheck

Expert Comment

ID: 13418527
Couldn't you just go through and .Hide each of the TabPages you don't need, and .Show the ones you intend to show again later?

Author Comment

ID: 13418538
If u mean the visible property then No as this does not seem to work.
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 12

Expert Comment

ID: 13418553
I did just try using the Hide and Show property... didn't seem to work for some reason as anwarmir said...

I did try this and it seems to show as visible though

    Dim x As New TabPage("Hello")
    Dim y As New TabPage("Hello2")

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    End Sub
LVL 12

Expert Comment

ID: 13418560

replace the initial adding to this

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    End Sub

This will allow duplicate pages of x to be added, so you may want to check that there isn't already an "X" page in the control

Author Comment

ID: 13422536
For some reason I cant get it to work...I lost all my tabs in design view and to get the latet one again from sourcesafe. Can u please help...On the form load event I remove the tabs to show only the default ones. But depending on the functionality being invoked i am adding the code like this. How would I adapt the code with regards to what u said previouly. Also how can i maintain the position of the tab so that tabAdjustment is always the last one.

        ''Configure from for Maintain Payments
        'If Me.FormName = CashAppFormType.MaintainPayment Then
        '    Select Case Me.Paymentmethod
        '        Case "ca_Pymt_Cash"
        '            TabPayment.Controls.Add(TabCash)
        '            TabPayment.Controls.Add(TabAdjustment)
        '        Case "ca_Pymt_CC"
        '            TabPayment.Controls.Add(TabCreditCard)
        '            TabPayment.Controls.Add(TabAdjustment)
        '        Case "ca_Pymt_Check"
        '            TabPayment.Controls.Add(TabCheck
        '            TabPayment.Controls.Add(TabAdjustment)

        '        Case "ca_Pymt_Draft"
        '            TabPayment.Controls.Add(TabBankDraft)
        '            TabPayment.Controls.Add(TabAdjustment)

        '        Case "ca_Pymt_EFT"
        '            TabPayment.Controls.Add(TabFundsTransfer)
        '            TabPayment.Controls.Add(TabAdjustment)
        '    End Select
        'End If
LVL 12

Accepted Solution

S-Twilley earned 1000 total points
ID: 13422835
Just to prevent duplicate Tab Pages being added, I've written a short method

    Sub AddTabPage(ByRef NewPage As TabPage, ByRef ParentTabControl As TabControl)
        If Not ParentTabControl.TabPages.Contains(NewPage) Then
            ' Tab page is currently not part of the Parent Tab Control
            ' Add any code here if you like
        End If
    End Sub


Then with your Select Case

        If Me.FormName = CashAppFormType.MaintainPayment Then
            Select Case Me.Paymentmethod
                Case "ca_Pymt_Cash"
                    AddTabPage TabCash, TabPayment
                    AddTabPage TabAdjustment, TabPayment

                Case "ca_Pymt_CC"
                    AddTabPage TabCreditCard, TabPayment
                    AddTabPage TabAdjustment, TabPayment

                Case "ca_Pymt_Check"
                    AddTabPage TabCheck, TabPayment
                    AddTabPage TabAdjustment, TabPayment

                Case "ca_Pymt_Draft"
                    AddTabPage TabBankDraft, TabPayment
                    AddTabPage TabAdjustment, TabPayment

                Case "ca_Pymt_EFT"
                    AddTabPage TabFundsTransfer, TabPayment
                    AddTabPage TabAdjustment, TabPayment
            End Select
        End If


As for making sure tabAdjustment is the last one, Im not sure how to adjust the order of tabpages once they have been added, but a new tab page is always added to the end of the list as far as i know, so as long as you add TabAdjustment last, it should be fine

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month15 days, 8 hours left to enroll

743 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