Re: Hiding and showing tabs
I tried once to hide a tab in similar way and after trying and trying it did not work...
What I did in the end was to disable the tab - maybe this idea will push you in the right direction. Instead hiding tabs you don't want, disable them - thats the best I was able to do it and most importantly I was satisfied with that solution...
Re: Hiding and showing tabs
That probably wont do, as some tabs need to be filtered out.
Is it possible to move a tab to a different tabcontrol and then moev it back?
Re: Hiding and showing tabs
if you dont need the tabpage back then you can dispose it
Re: Hiding and showing tabs
Yeah, but I need it back.
Re: Hiding and showing tabs
ok try this. it requires a little bit of tweaking, but gives you the basic idea.
vb Code:
Dim tp As TabPage
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
tp = Me.TabControl1.TabPages(2)
Me.TabControl1.TabPages.Remove(tp)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.TabControl1.TabPages.Add(tp)
End Sub
Re: Hiding and showing tabs
I figured it out, I'll psot the code soon.
I'm adding comment atm.
Code:
'show tab
Dim txt As Object
Dim tabp As TabPage
'loop through all tabs in
For Each tabp In TabControl2.TabPages
'loop through all objects in the tab
For Each txt In tabp.Controls
'check if it's a label
If TypeOf txt Is Label Then
'if it's a label, see what the text is
If txt.text = "Autozone" Then
'if it's that text, move it to the first tabcontrol
'it'll be removed from the second tab
TabControl1.TabPages.Add(tabp)
End If
End If
Next
Next
Code:
'hide tab
Dim txt As Object
Dim tabp As TabPage
'loop through first control
For Each tabp In TabControl1.TabPages
For Each txt In tabp.Controls
If TypeOf txt Is Label Then
If txt.text = "Autozone" Then
'add to second
TabControl2.TabPages.Add(tabp)
End If
End If
Next
Next
This code works fine :)
Re: Hiding and showing tabs
vb Code:
If TypeOf txt Is Label Then
'if it's a label, see what the text is
If txt.text = "Autozone" Then
you can combine these two lines using AND
Re: Hiding and showing tabs
You can just remove the TabPage from the TabPages collection. If you still need it later, just store it in a (probably global) variable of type TabPage, or if you need multiple pages, of type List(Of TabPage). Then you can simply Add it back in at a later time. That will add it to the end though, if you need it at a specific place I think the only way you can do that is by taking out all tabpages, putting them in some collection (List(Of TabPage)), using Insert on that collection (which is not available for a TabPageCollection), and then putting them back into the TabControl.