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 :
Dim Frm As New NewTabPage
Dim MoreTabs As TabPage = Frm.TabPage1
Dim i As Integer
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 :
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
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 ?