Hi Im trying to Populate my datagridview from data scraped off of webpage i Want to be able to report progress when datagrid finished updating.. with a progressbar..
Please Help!!!!!! Thank You..

Heres My code

 Dim theElementCollection As Windows.Forms.HtmlElementCollection
        theElementCollection = Form1.WebBrowser2.Document.GetElementsByTagName("a")
        For Each curElement As HtmlElement In theElementCollection
            Form1.DataGridView1.Rows.Add(curElement.GetAttribute("title"), (curElement.GetAttribute("href")))
            Dim numberOfRows = Form1.DataGridView1.Rows.Count - 1
            Dim i As Integer = 0
            While i < numberOfRows - 2
                For ii As Integer = (numberOfRows - 2) To (i + 1) Step -1
                    If Form1.DataGridView1.Rows(i).Cells(0).Value.ToString() = Form1.DataGridView1.Rows(ii).Cells(0).Value.ToString() Then
                        Form1.DataGridView1.Rows.Remove(Form1.DataGridView1.Rows(ii))
                        numberOfRows -= 1
                    End If
                Next
                i += 1
            End While
        Next

Recommended Answers

All 2 Replies

In order to use a ProgressBar you have to know the total number of rows before you start. If you don't know this before you start you will have no way of knowing where you are in the transfer. The following code assumes you have 142 rows. Every time you add a new row you increment the value of the ProgressBar by one. The line with the Sleep is only there to slow things down so you can see the ProgressBar moving.

Dim numRows As Integer = 142

ProgressBar1.Maximum = numRows
ProgressBar1.Value = 0

For i As Integer = 1 To numRows
    ProgressBar1.Value += 1
    System.Threading.Thread.Sleep(50)
Next

Thank you for your help sir.. im sticking with ProgressBar1.PerformStep()

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.