access array across multiple forms

  • Thread starter Thread starter FrAxElAnK
  • Start date Start date
F

FrAxElAnK

I am creating a program with 2 forms and on the first one i have
created an arraylist. On the second one I want to call the arraylist
to display its contents in a textbox. I am having trouble figuring out
how to make the arraylist that is on the first form visible to the
second form so I can have some code display its contents. Any help
would be greatly appreciated. Thanks

Alex
 
I am creating a program with 2 forms and on the first one i have
created an arraylist. On the second one I want to call the arraylist
to display its contents in a textbox. I am having trouble figuring out
how to make the arraylist that is on the first form visible to the
second form so I can have some code display its contents. Any help
would be greatly appreciated. Thanks

Alex

You can make a property on the form that contains the ArrayList. Make
this property return the ArrayList, and then the other form can use
this property to access the arrayList.
 
You can make a property on the form that contains the ArrayList. Make
this property return the ArrayList, and then the other form can use
this property to access the arrayList.

forgive my stupidity, but how exactly do you do that?
 
Alex,

There are a lot of methods,

First of all you can change the constructer from your second form and make
it overloaded.

Public sub New (Byval MyArraylist as Arraylist)
MyForm2Arraylist = MyArratlist
End Sub
Private MyForm2ArrayList as Arraylist

However you can pass the reference as well as property or whatever.

Cor
 
forgive my stupidity, but how exactly do you do that?

public class MyForm
private theList As new ArrayList()

public readonly property TheList() As ArrayList
get
return me.theList
end get
end property
end class
 
Back
Top