2 Replies - 421 Views - Last Post: 14 September 2019 - 09:36 PM Rate Topic: -----

#1 cpssantos   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 14-September 19

Update listbox of form2 from form1 withouting creating form2 again

Posted 14 September 2019 - 07:59 PM

I have a project that passes data from Form1 to Form2, Form1 will be show in monitor1 and Form2 in monitor2. I'm achieving this result but it creates another instance of Form2 every time I want to update the data in Form2. Is there a way to update Form2 without creating a new one?
 
Public Class Form1

Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
        Dim OBJ As New Form2
        OBJ.ListBox1.Items.AddRange(ListBox1.Items)
        OBJ.ListBox2.Items.AddRange(ListBox2.Items)
        OBJ.Label1.Text = TextBox3.Text
        OBJ.Show()
    End Sub

End Class



I searched the internet but all I found is creating a new Form2 rather than updating the exisisting one.

Is This A Good Question/Topic? 0
  • +

Replies To: Update listbox of form2 from form1 withouting creating form2 again

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15359
  • View blog
  • Posts: 61,583
  • Joined: 12-June 08

Re: Update listbox of form2 from form1 withouting creating form2 again

Posted 14 September 2019 - 08:55 PM

Move line 4 to a global.
Was This Post Helpful? 1
  • +
  • -

#3 cpssantos   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 14-September 19

Re: Update listbox of form2 from form1 withouting creating form2 again

Posted 14 September 2019 - 09:36 PM

Works like a charm. Thanks very much
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1