Hi all,
my current project shows a single page tabcontrol with a datagridview. I read names from a mysql table, and create an additional tab page for each person (there's only ever going to be half a dozen or so, so it should be manageable).
I want to duplicate the controls on the first page onto each additional page as I add it. I have tried a couple of example I found on the net, but can't get them to work.

'Load Engineer Names, and create one tab for each engineer
            Dim myEngineerCounter As Integer = 0
            Dim myEngineerName(20) As String
            Dim myEngineerID(20) As Integer
            Dim myEngineerActive(20) As Boolean
            Dim dgvMonday As New DataGridView
            mySQLstring = "select idEngineers, EngineerName from engineers where engineeractive = 'y'"
            mySQLcmd.CommandText = mySQLstring
            mySQLdr = mySQLcmd.ExecuteReader
 
            Do While mySQLdr.Read()
                myEngineerCounter = myEngineerCounter + 1
                myEngineerID(myEngineerCounter) = Convert.ToString(mySQLdr(0))
                myEngineerName(myEngineerCounter) = Convert.ToString(mySQLdr(1))
                tabSchedules.TabPages.Add(myEngineerName(myEngineerCounter))
      '-----Here's where I add the dgv
                tabSchedules.TabPages.Item(myEngineerCounter).Controls.Add(dgvMonday)
            Loop

When I run the program, the tabs are created and named correctly but only the last page has the dgv on it. I guess this is because I can't have multiple controls on the form with the same name ("dgvMonday" in this case) so how do I duplicate the controls onto the new tabpages? I have tried to define dgvMonday as an array, but then get an error because you can't use an array with 'new'.
I have also looked at trying to duplicate the first tabpage, but cannot get that to work either.
The only other way I can see is to set up the tabcontrol with 20 tabpages, each with all the controls at design-time, and when the program is run it deletes unwanted tabpages. Seems a bit crude, and I feel there must be a tidier way of doing this.
Any ideas?

try this
:

'Load Engineer Names, and create one tab for each engineer
            Dim myEngineerCounter As Integer = 0
            Dim myEngineerName(20) As String
            Dim myEngineerID(20) As Integer
            Dim myEngineerActive(20) As Boolean
            Dim dgvMonday(20) As DataGridView
            mySQLstring = "select idEngineers, EngineerName from engineers where engineeractive = 'y'"
            mySQLcmd.CommandText = mySQLstring
            mySQLdr = mySQLcmd.ExecuteReader
 
            Do While mySQLdr.Read()
                myEngineerCounter = myEngineerCounter + 1
                myEngineerID(myEngineerCounter) = Convert.ToString(mySQLdr(0))
                myEngineerName(myEngineerCounter) = Convert.ToString(mySQLdr(1))
                tabSchedules.TabPages.Add(myEngineerName(myEngineerCounter))
      '-----Here's where I add the dgv
             
dgvMonday(myEngineerCounter)=New DataGridView tabSchedules.TabPages.Item(myEngineerCounter).Controls.Add(dgvMonday(myEngineerCounter))
            Loop
This question has already been answered. Start a new discussion instead.