arraylist to use in another form

C

Chris

al said:
I'm not seeing things right today. I have an arraylist I create and load
in one form. To display the information from the array list I'm opening a
richtextbox in another form - stupid time - how do I pass the array list to
the load function of the new form??

//al

Class FormArrayListPassing
dim mArrayList as ArrayList
sub New(iArrayList as ArrayList)
initializeComponents
mArrayList = iArrayList
end sub
End Class
 
A

al jones

I'm not seeing things right today. I have an arraylist I create and load
in one form. To display the information from the array list I'm opening a
richtextbox in another form - stupid time - how do I pass the array list to
the load function of the new form??

//al
 
C

Cerebrus

Well...

Might be a hundred ways to do this... Don't worry I won't and can't
enumerate all hundred ;-)

1. Create a Public property of type Arraylist within the New form.
Before showing this newForm, set the value of the property to your
ArrayList.

2. Create an overloaded Sub New procedure (constructor) for your New
form, which accepts an ArrayList as parameter. Then call that method
instead of the usual constructor.

Rest of the 98 ways... umm... maybe next time ? lolz

Regards,

Cerebrus.
 
A

al jones

I'm not seeing things right today. I have an arraylist I create and load
in one form. To display the information from the array list I'm opening a
richtextbox in another form - stupid time - how do I pass the array list to
the load function of the new form??

//al

I'm not really talking to myself - thank you both. Once I see what your
code does Chris (thanks to Marks suggestion) it makes sense.

There are days I'd love to go back to the simplicity of codeing COBOL for a
mainframe - and then there are days where I'd gladly drop every computer I
have off the top of the Eiffel Tower!

Thank you both //al
 
C

Cor Ligthert [MVP]

Al in the same way as you would do it in Cobol if that was a Call by
overloading the Sub New in your second form.

But mostly is it easier to make in this case your arraylist friend in form 1
Set a property in your second form and than use that (it can as well with a
field, in the way I show it you here quick and dirty)

Form1
Friend MyArrayList as new arraylist

Form2
Friend myArrayList as arraylist

Form1 procedure
dim frm2 as Form2
frm2.myArrayList = me.myArraylist
frm2.show
'I prefer this with
frm2.showdialog, with the show you can get complications.

I hope this helps,

Cor
 
A

al jones

Cor, as Xerebus said, there are probably 100 different ways to do it... I
like yours, but had already used his (which works).

Thanks for the additional education ...

The last COBOL *I* wrote was something like COBOL 74 (on an HP series 3) -
it was all single (as I recall) programs, there was no call yet, that came
about in COBOL 80 (or later), didn't it??

//al
 
C

Cerebrus

Hmmm... "Xerebrus" is a nice name too ! Thanks for that new nick, Al,
it's cool ! LOL !

Regards,
 
A

al jones

Hmmm... "Xerebrus" is a nice name too ! Thanks for that new nick, Al,
it's cool ! LOL !

Regards,

<chuckle> Oops, sorry guy, it as getting late and I was thinking about
getting my old bod to bed - slippery fingers and all that. Glad you like
the alternative form, but did you notice that you also further altered it??

//al
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top