I have a form the stores selected items from a checkedlistbox into an listbox on another form.
'Form2
Public Sub New(ByVal Citems As List(Of String), ByVal Citems2 As List(Of String))
InitializeComponent()
ListBox1.Items.AddRange(Citems.ToArray)
ListBox2.Items.AddRange(Citems2.ToArray)
Private Sub Cancel_Click(sender As Object, e As EventArgs) Handles Button2.Click
'Cancel the form and returns to Form 1
ListBox1.Items.Clear()
ListBox1.Refresh()
ListBox2.Items.Clear()
ListBox2.Refresh()
Me.Close()
End Sub
'Form 1
Dim Citems As New List(Of String)
Dim Citems2 As New List(Of String)
Private Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click
For Each I As String In CheckedListBox1.CheckedItems
Citems.Add(I)
Next
For Each I As String In CheckedListBox2.CheckedItems
Citems2.Add(I)
Next
Dim SecondForm As New Form2(Citems, Citems2)
SecondForm.Show()
This is the code that I have that is suppose to clear the listboxes and close the form. Problem is that when it is opened again the previously selected items are still in the listbox. How can I clear out the data without complete closing the application?
Citems.Add(I)
and the other will just add new items to that master list the next time they click submit – Ňɏssa Pøngjǣrdenlarp