Link to home
Start Free TrialLog in
Avatar of anwarmir
anwarmir

asked on

How to make a tabpages visible

Hi I have an issue. I have removed certain tabpages for a tabcontrol as follows
   'Display Default Tab
            TabPayment.Controls.Remove(TabCheck)
            TabPayment.Controls.Remove(TabBankDraft)
            TabPayment.Controls.Remove(TabFundsTransfer)
            TabPayment.Controls.Remove(TabCreditCard)
            TabPayment.Controls.Remove(TabAdjustment)
            TabPayment.Controls.Remove(TabCash)


however if i want to redisplay certain tabs using the syntax below it does not work. Any Ideas?
    TabPayment.Controls.Add(TabCheck)

Avatar of S-Twilley
S-Twilley

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"
        TabControl1.Controls.Add(x)
        x.Visible = True


If this isn't working, post some more of your code up including the declaration of TabCheck
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?
Avatar of anwarmir

ASKER

If u mean the visible property then No as this does not seem to work.
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
        TabControl1.Controls.Add(x)
        TabControl1.Controls.Add(y)
    End Sub

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

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TabControl1.TabPages.Add(x)
    End Sub
actually...

replace the initial adding to this

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        TabControl1.TabPages.Add(x)
        TabControl1.TabPages.Add(y)
    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
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
ASKER CERTIFIED SOLUTION
Avatar of S-Twilley
S-Twilley

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial