Hi,
I have datatable with three rows of data that will increase

I want each row to fill lables, checkboxes and textboxes on their own tab of my tab control


I have created a Template tabpage but when i try to add the other dynamic tabpages they are all blank

The form cantains: 1 x TabControl = "TabSiteDetail"
1 x TabPage = "TabArea01"
1 x label (on TabArea01) = "lblPingResponse"
1 x Checkbox (on TabArea01) = "chkMonitorSite"
1 x Textbox (on TabArea01) = "txtSiteStatus"
Here is my code

Dim TabSiteDetailTemplate As New TabPage

        TabSiteDetailTemplate = TabArea01
        For Each SQLRow In SQLTable.Rows
            Dim NewTabPage As New TabPage
            NewTabPage = TabSiteDetailTemplate

            NewTabPage.Name = "tab" & SQLRow("TX")
            NewTabPage.Text = SQLRow("SiteName")

            TabSiteDetail.TabPages.Add(NewTabPage)
        Next

That will create blank tabs then let you add new controls
but you need to Dim each control which produces a limit

I have modified the code to allow for control arrays
and fill the Controls from a timer

Here is the code (Posted as it could help somebody else)

Private General as new clGeneral 'Class with General SQL Code
    Private SQLTable As New DataTable
    Private TabSiteDetail(0) As TabPage
    Private lblPingResponseArr(0) As Label
    Private chkMonitorArr(0) As CheckBox
    Private txtSiteStatusArr(0) As TextBox

    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim SQLRow As DataRow
        Dim TabCount As Integer = 0

        SQLTable = General.GetSiteList 'Returns a DataTable

        For Each SQLRow In SQLTable.Rows
            TabSiteDetail(TabCount) = TabArea1
            lblPingResponseArr(TabCount) = lblPingResponse
            chkMonitorArr(TabCount) = chkMonitor
            txtSiteStatusArr(TabCount) = txtSiteStatus

            TabCount = TabSiteDetail.Length
            ReDim Preserve TabSiteDetail(TabCount)
            ReDim Preserve lblPingResponseArr(TabCount)
            ReDim Preserve chkMonitorArr(TabCount)
            ReDim Preserve txtSiteStatusArr(TabCount)

            TabSiteDetail(TabCount) = New TabPage
            lblPingResponseArr(TabCount) = New Label
            chkMonitorArr(TabCount) = New CheckBox
            txtSiteStatusArr(TabCount) = New TextBox

            lblPingResponseArr(TabCount).Left = lblPingResponse.Left
            chkMonitorArr(TabCount).Left = chkMonitor.Left
            txtSiteStatusArr(TabCount).Left = txtSiteStatus.Left

            lblPingResponseArr(TabCount).Top = lblPingResponse.Top
            chkMonitorArr(TabCount).Top = chkMonitor.Top
            txtSiteStatusArr(TabCount).Top = txtSiteStatus.Top

            lblPingResponseArr(TabCount).Text = "Awaitng Response"

            TabSiteDetail(TabCount).Text = SQLRow("SiteName")

            TabSiteDetail(TabCount).Controls.Add(lblPingResponseArr(TabCount))
            TabSiteDetail(TabCount).Controls.Add(chkMonitorArr(TabCount))
            TabSiteDetail(TabCount).Controls.Add(txtSiteStatusArr(TabCount))

            TabCtrlSiteDetail.TabPages.Add(TabSiteDetail(TabCount))
        Next
This question has already been answered. Start a new discussion instead.