move tabpages

izzyq8

Member
Joined
Dec 29, 2007
Messages
21
Programming Experience
Beginner
ok final help i hope :p

how do i choose one certain type of tab after i opned it
for example i want tab 6 to go inside a new group box ive created

VB.NET:
Me.Controls.Add(New GroupBox)

i want that everytime i click a button all the open tabs go into seprate group box's
any FINAL help?:p
 
That is unclear... you want to add Groupbox to a form, then a TabControl into it?
VB.NET:
dim gb as new groupbox
me.controls.add(gb)
dim tc as new tabcontrol
gb.controls.add(tc)
 
i already have the tabcontrol on another form with the code used in my first post
what i need to do is take each tabpage from the tabcontrol on the first form and insert it into a seprate groupbox on a diffrent form
if i have 5 tabs then i will have 5 groupboxes

am i making any sense :p
 
TabPage cannot be added to a GroupBox. TabPages can only be added to TabControls.
 
ok new probelem( dont hate me just yet :p)
with the following code it takes whatever is in form1 and puts it into form2
there is a tabcontrol with tab pages in form 1
what this code does is take each tab sepreatly and puts it into a seprate tabcontrol
it works if there is only one tab
anymore and it tells me its out of bound


VB.NET:
      Dim i As Integer = 0
        For i = 0 To Form1.TabControl1.TabPages.Count - 1

            Dim groupBox1 As New GroupBox
            Dim tabs As New TabControl
            tabs.Location = New Point(15, 15)
            groupBox1.Controls.Add(tabs)
            tabs.Controls.Add(Form1.TabControl1.TabPages(i))
            groupBox1.Enabled = True
            groupBox1.Text = "MyGroupBox"
            groupBox1.Dock = DockStyle.Top
            Me.Controls.Add(groupBox1)
        Next

it gives me an error on tabpages
any solutions?


also is there a way to start a webpage at a certain location?
 
VB.NET:
For Each tp As TabPage In TabControl1.TabPages
   '...
   tabs.TabPages.Add(tp)
Next
A TabPage is added to the TabPages collection, not to Controls collection.
 
The code I posted is the loop. Do whatever you want in the loop, I just added an example of how to add each tp with the TabPages.Add method.
 
its working the way i want it except a new problem has risen
the tabs are deleted from the first form and only appear on the second form
why is it doing that? how can i make it stop? what is ur favorite type of cake john?
 
They are doing that because a TabPage can only be one place at the same time. It's like you set the location for something, it can't be both here and there.
 
Do the opposite:
VB.NET:
'move a page from tabcontrol1 to tabcontrol2:
tabcontrol1.tabpages.add(tabcontrol2.tabpages(0)) 
'move a page from tabcontrol2 to tabcontrol1:
tabcontrol2.tabpages.add(tabcontrol1.tabpages(0))
Favorite VB.Net programming related cake: "piece of cake!" ;)
 
VB.NET:
 For Each tp As TabPage In TabControl1.TabPages

            Dim toob As New TabControl
            Dim taab As New TabPage
            Dim foom As New Form
            foom.Controls.Add(toob)
            toob.Controls.Add(tp)
            foom.Visible = True
next

its working perfectly except there over each other
VB.NET:
'move a page from tabcontrol1 to tabcontrol2:
tabcontrol1.tabpages.add(tabcontrol2.tabpages(0)) 
'move a page from tabcontrol2 to tabcontrol1:
tabcontrol2.tabpages.add(tabcontrol1.tabpages(0))
how do i implement that code to my code seeing as i have no tabcontrol2 ?
 
Last edited:
how do i implement that code to my code seeing as i have no tabcontrol2 ?
You have no tabcontrol 2? If you only have one tabcontrol you can't move tabpages between tabcontrols.
 
Back
Top