Hello Daniweb Community,
I was wondering if there is a way to reset a tabcontrol.
What I'm wanting to do is have it so when the user will click New it will reset all the tabpages to the way they were when they started the program up.

I tried this

TabControl1.TabPages.Clear()
TabControl1.TabPages.AddRange({TabPage1, TabPage2, TabPage3, TabPage4})

But all it does it remove the pages then re-add them with all the data still there.

What's on those tab pages? Am sure it's possible to write a generic routine that can reset your components.

Some have textboxes, pictureboxes, groupboxes (with radiobuttons).
I don't really want to have to clear them manually like each control (Textbox1.Text = Nothing, PictureBox1.Image = Nothing, RadioButton1.Check = True, etc...)

You can make a function, pass a tab as parameter. In that function loop all controls of the tab and depending on the type clear the text, remove the image and so on.

For Each cntrl As Control In TabPage1.Controls // make tabpage1 a parameter
    If TypeOf cntrl Is PictureBox Then
        cntrl.Image = Nothing
    End If

    If TypeOf cntrl Is TextBox Then
        cntrl.Text = Nothing
    End If

    // and so on
Next
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.