0

I have a tab control with 2 tab pages and a menu strip with 2 items. when I click item 1 in menuStrip, I want to view ONLY TAB PAGE 1.

I tried

Private Sub item1ToolStripMenuItem_Click(...)
    TabPage2.Select()        
    TabPage2.Show()
    TabPage2.Visible = True
    TabPage1.Visible = False
End Sub
andy
  • 5,979
  • 2
  • 27
  • 49
kiaara
  • 11
  • 1
  • 9

2 Answers2

0

If you are using TablControl, following is feasible. The fllowing post has alternative solutions as well.

TabControl1.TabPages.RemoveByKey("Selection")
bonCodigo
  • 14,268
  • 1
  • 48
  • 91
  • http://msdn.microsoft.com/en-sg/library/system.windows.forms.tabcontrol.tabpagecollection.removebykey.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1 – bonCodigo Feb 26 '13 at 11:38
  • i do not want to remove tab pages but view only 1 page as per the selected menu. Consider i have a menu tool with 2 items edit and order! and a tab control with 2 tab pages - edit and -order `that is, if i select **edit** in menu, i want to open the edit tab in tab pages or view only the "EDIT TAB" and if i select **order** in menu, open order tab in tab collection pages` **hope its not confusing** – kiaara Feb 27 '13 at 23:43
  • @kiaara, Either you have to go with "PageEnabled" property or you need to Add/Remove TabPages at run time – andy Feb 28 '13 at 12:57
0

There is no any visible property for TABPAGES........... Instead of it you can use PageEnabled = True/False. Or you can remove the tabpages from tab control and add back.

You can do like this

tabControl1.TabPages.Add(YourSpecificTabPage)
tabControl1.TabPages.Remove(YourSpecificTabPage)

Refer : 1. VB.Net Hide Tabpage 2. Programatically hide/remove tabpages in VB.NET

Community
  • 1
  • 1
andy
  • 5,979
  • 2
  • 27
  • 49
  • but i want to view only a specific tab page from the collection as per the selected menu item – kiaara Feb 26 '13 at 11:19
  • i did try this today sir but it keeps adding new tab each time you click!! – kiaara Feb 28 '13 at 12:14
  • no i do not need to remove tab page, instead view a specific TAB PAGE based on the selection!!! But it is fine, i will try some other method! Aniways thanks for the help! – kiaara Feb 28 '13 at 12:55