| | | Forum Newbie
       
Group: Forum Members Last Login: 10/10/2008 4:02:17 PM Posts: 4, Visits: 4 |
| I have a program that so far downloads an XML file, parses it, stores it in an ArrayList and then reads the ArrayList to add items to a Checked List Box, which is on a different form from where the ArrayLists are made and stored as public class variables.
After I construct the ArrayLists I used the following bit of
testForm.testList.Items.Add("Test String", True)
The code runs properly and can be accessed again using
testForm.testList.Items()
When I hide the current form and show "testForm" (the form holding the Checked List Box) none of the items I've added show up. Any ideas? |
| | | | Forum Newbie
       
Group: Forum Members Last Login: 10/10/2008 4:02:17 PM Posts: 4, Visits: 4 |
| | Another note, all this code about downloading XML, parsing it, and adding items into a checked list box is done inside a background worker. I'm not sure if that will make a different. |
| | | | 
Forum God
       
Group: Forum Members Last Login: Yesterday @ 3:21:14 PM Posts: 845, Visits: 5,124 |
| | I think you are right it is in your background worker. You can't directly commucate with controls. Try this: Set the WorkerReportsProgress to true. Private Sub Start_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Start.Click BackgroundWorker1.WorkerReportsProgress = True BackgroundWorker1.RunWorkerAsync() End Sub
In the DoWork: Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork Dim x As Long = 0 Do While x < 100 BackgroundWorker1.ReportProgress(1, "Test " & CStr(x)) x += 1 Loop End Sub
The one is just there because I have to have something there. The string is what you want to put in the checked listbox. In the ProgressChanged: Private Sub BackgroundWorker1_ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged Form2.CheckedListBox1.Items.Add(e.UserState) End Sub Edit: You cannot see anything until the worker has finished.
Wayne I know enough to be dangerious. It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living. |
| | | | Forum Newbie
       
Group: Forum Members Last Login: 10/10/2008 4:02:17 PM Posts: 4, Visits: 4 |
| | That was it! Thanks a lot! Topic solved. |
| |
|
|