Click here to Skip to main content
15,881,881 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a clone tabpage which has a datagridview.
I tired to fill datagridview in each tabpage , because it's only fill on tabpage1
This is my code for cloning tab :
VB
Dim Frm As New NewTabPage
        Dim MoreTabs As TabPage = Frm.TabPage1
        Dim i As Integer ' = 1
        For i = 1 To TabControl1.TabPages.Count
            MoreTabs.Text = "TabPage" & i + 1
        Next i
        TabControl1.Controls.Add(MoreTabs)
        Frm.Dispose()

This is my code for fill datagridview with backgroundworker :
VB
Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        MyConnection = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + FPathTab + ";Extended Properties=Excel 12.0;")
        MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [" & CSheetTab1 & "]'", MyConnection)

        DtSet = New System.Data.DataSet
        DtSet.Clear()
        MyCommand.Fill(DtSet)
    End Sub

VB
Private Sub BackgroundWorker1_RunWorkerCompleted(sender As Object, e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
        Me.TabControl1.TabPages(TabControl1.SelectedIndex).Text = Trim("Asset" & CTabName & " 20" & CTabName1)
        Me.DataGridView1.DataSource = DtSet.Tables(0)
        dv = DtSet.Tables(0).DefaultView
End Sub


Please Help, how to fill datagridview with different data for each tabpages ?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900