Hi guys, I searched and googled, but I still can't wrap my head around this one. First, a small section of code pertaining to my issue:
The intention here is to search for entries listed in a datagridview. If the item is found, it is added to an Access table, and removed from the datagrid, otherwise, it remains in the datagrid.
(RecordAdded is a public var being setup by one of the called sub, to determine if the record was added to the table or not.)
My problem happens when I remove the row from the datagrid. Everything "shifts up", so the for each ends up skipping entries.
My ugly solution was to have a "goto restart" as you can see commented out, but that's definitely not efficient, as it then restarts from the beginning of the datagraidview list and searches for some that have already been searched.
I can't change row.index, as it is read only.
Any ideas any one??
Cheers,
Realm174
Code:
Restart:
For Each row In DataGridView1.Rows
If row.Index = -1 Then Exit For
If (DataGridView1.Item(1, row.Index).Value = True) Or _
(DataGridView1.Item(1, row.Index).Value = CheckState.Checked) Then
count = count + 1
If count > Val(Trim(ret)) Then
Exit Sub
End If
Dim SearchItem As String = DataGridView1.Item(0, row.Index).Value
lblprocessing.Text = "Processing " & SearchItem
Me.ProgressBar.Value = count
Me.Refresh()
MainForm.SearchBox.Text = SearchItem
MainForm.AmazonSearch(SearchItem, "All", BatchMode)
If RecordAdded Then
DataGridView1.Rows.Remove(row)
MainForm.Close()
RecordAdded = False
'GoTo restart
End If
End If
Next
The intention here is to search for entries listed in a datagridview. If the item is found, it is added to an Access table, and removed from the datagrid, otherwise, it remains in the datagrid.
(RecordAdded is a public var being setup by one of the called sub, to determine if the record was added to the table or not.)
My problem happens when I remove the row from the datagrid. Everything "shifts up", so the for each ends up skipping entries.
My ugly solution was to have a "goto restart" as you can see commented out, but that's definitely not efficient, as it then restarts from the beginning of the datagraidview list and searches for some that have already been searched.
I can't change row.index, as it is read only.
Any ideas any one??
Cheers,
Realm174