I have two forms with one listbox on each form. How can I show what I have in the listbox on form1 on form2. I have a button on form1 to go to form2

Private Sub btnform2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnform2.Click
        Form2.Show()
        Dim sTemp As String = TextBox1.Text & ":" & textbox2.Text & ":" & textbox3.Text & ":" & textbox4.Text & ":" & textbox5.Text
        Form2.ListBoxFonts.Items.Add(sTemp) 'add to the listbox
    End Sub

But when I click the button it goes to the form2 but it only shows one list and nothing else. When I go to form1 to add another list, it comes up with the listbox on form2 with two list, but when I go to my form2, it only shows the latest one I put in, it never shows two or more list, its probably just one line of code, but could someone help me

I basically know what I want to do

show lisbox1 on form1 to listbox1 on form2

but I dont know how to code this, like I said its one line of code, but I just dont know how to actually code it

If you want to add list item of listbox1 of from1 to listbox1 of Form2

write the below codes in form2_load event....

Dim a As Integer
ListBox1.Items.Clear()
For a = 0 To Form1.ListBox1.Items.Count - 1 Step 1
    ListBox1.Items.Add(Form1.ListBox1.Items.Item(a).ToString)
Next

If you want to add textbox's text of from1 to listbox1 of Form2

write the below codes in form2_load event....

ListBox1.Items.Clear()
ListBox1.Items.Add(Form1.textbox1.text.ToString)
ListBox1.Items.Add(Form1.textbox2.text.ToString)
ListBox1.Items.Add(Form1.textbox3.text.ToString)
ListBox1.Items.Add(Form1.textbox4.text.ToString)
ListBox1.Items.Add(Form1.textbox5.text.ToString)

I first code is what I needed, thanks

I am trying to do something similar:

Form called report selector, shows all the reports but there are some duplicates in them, Report selector form has a listbox, the user will select all the reports which are the ones he/she will print often and click a submit button.

Form called report printer, has a listbox which displays the reports which were selected to be printed.

i just cant get the listbox to show the reports selected from the form report selector.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.