I have TabControl with 1 TabPages and contains DataGridView. I create TabPages2 from TabPages1 with code :
Dim Frm As New TabFormPage
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()
TabPages2 Controls identical to TabPages1
If I fill DataGridView with BackgroundWorker in TabPages1 , it was working . But if I fill DataGridView in every New TabPages ( eg TabPages2 ) from different sources , it was not working (DataGridView in TabPages2/each New TabPages is empty/nothing) . It always fills Tabpages1 DataGridView
How to fill every DataGridView in every New TabPages with identical controls ? Here's my code to fill DataGridview :
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
DataGridView1.DataSource = DtSet.Tables(0)
dv = DtSet.Tables(0).DefaultView
MaxRecords = DtSet.Tables(0).Rows.Count
MyConnection.Close()
DataGridView1.Columns("F20").Visible = False
DataGridView1.Columns("F21").Visible = False
DataGridView1.Columns("F22").Visible = False
End Sub
Thanks for your help
Aucun commentaire:
Enregistrer un commentaire