Hi guys I am trying to implement this bit of code in a BGW have it in a Sub now but need it in BGW
Sub Code Code:
If Not String.IsNullOrEmpty(CStr(Dialog1.ComboBox3.SelectedItem)) Then Dim tName As String = Dialog1.ComboBox3.SelectedItem.ToString For Each item As String In Dialog1.CheckedListBox1.CheckedItems() For i = table.Rows.Count - 1 To 0 Step -1 If (table.Rows(i)(tName)).Equals(item) Then table.Rows.RemoveAt(i) End If Next Next End If
I have a button that shows a dialogbox that contains various combo, text and checklist boxesx based on the selectedindex of the comboBox a checklist box is populated with all the unique fields in that column
What would be the most "proper" way to do this? This is what i have so far:
Sub Code:
Private Sub DelRecs() If Not String.IsNullOrEmpty(CStr(Dialog1.ComboBox3.SelectedItem)) Then Dim tName As String = CStr(Dialog1.ComboBox3.SelectedItem) For Each item As String In Dialog1.CheckedListBox1.CheckedItems() list.Add(item) Next BackgroundWorker5.RunWorkerAsync() End If End Sub
bgw Code:
Private Sub BackgroundWorker5_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker5.DoWork Dim worker As System.ComponentModel.BackgroundWorker = DirectCast(sender, System.ComponentModel.BackgroundWorker) For Each item As String In list For i = table.Rows.Count - 1 To 0 Step -1 If (table.Rows(i)(tName)).Equals(item) Then table.Rows.RemoveAt(i) End If Next Next End Sub
declarations Code:
Dim item As String Dim list As New List(Of String) Dim tName As String
I am really confused as I have something very similiar in another BGW and it works fine
But something tells me I am not doing this properly
Thanks




Reply With Quote