0

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

Edited by TheGuy831

2
Contributors
2
Replies
17
Views
6 Months
Discussion Span
Last Post by TheGuy831
2

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
0

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

This question has already been answered. 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.