Dear brother
Sorry for my bad english
Please help me in this case
I import with big data to Datagridview
It's take long time, and i want to using progessbar for wait
I try to do this
But it's seem not good
Please help me
Thank you so much!
Inline Code Example Here
Private Sub btn_test_Click(sender As Object, e As EventArgs) Handles btn_test.Click
pro_bar.Style = ProgressBarStyle.Marquee
pro_bar.MarqueeAnimationSpeed = 20
pro_bar.Refresh()
BackgroundWorker1.RunWorkerAsync()
End Sub
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Dim MyConnection As OleDbConnection
Dim ExcelAdapter As OleDbDataAdapter
Dim ExcelDataSet As DataSet
MyConnection = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; " + _
"Data Source=C:\EDUCATION\canidate_tem1.xlsx;Extended Properties=Excel 12.0;")
Try
ExcelAdapter = New System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1$]", MyConnection)
ExcelDataSet = New System.Data.DataSet
ExcelAdapter.Fill(ExcelDataSet)
e.Result = ExcelDataSet
MyConnection.Close()
Catch ex As Exception
e.Result = ex
End Try
End Sub
Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
If TypeOf e.Result Is DataSet Then
Dim ds As DataSet = CType(e.Result, DataSet)
DataGridView1.DataSource = ds.Tables(0)
Me.Text = ds.Tables(0).Rows.Count & " ROW(S) FOUND" & " - " & ds.Tables(0).Columns.Count - 1
'ProgressBar1.Style = ProgressBarStyle.Continuous
ElseIf TypeOf e.Result Is Exception Then
MessageBox.Show(CType(e.Result, Exception).Message)
End If
End Sub