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
    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;")
            ExcelAdapter = New System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1$]", MyConnection)
            ExcelDataSet = New System.Data.DataSet
            e.Result = ExcelDataSet
        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
1 Year
Discussion Span
Last Post by Reverend Jim

I can't try your example locally but I have a couple of suggestions. First, I suggest you have a look at this tutorial about Background Threads. It explains how to use delegates to update foreground controls (which you will need to update a progress bar). The second thing is a detail about progress bars. In order to display how much of a task has completed, it has to know the definition of completed. For your example, you have to tell it how many records will be displayed once the loading is complete. If you don't know then an alternative would be to update a label with the number of records loaded (again, using a delegate). At least that will provide feedback to the user.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.