By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,728 Members | 1,104 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,728 IT Pros & Developers. It's quick & easy.

sharing objects controls between forms???

P: n/a
frmMISRoutine is the 3rd form in myApp.
the following code is in the 2nd form of myApp.
I don't get any errors but it never builds the array list.
Can you access another foprms control in this way.
I have accessed variables thru setReceive etc but have not tried to access
an actual control.

Dim LogtoSet1 As New ArrayList
Dim frmMISRoutine As New Routines

For Each Item As Object In frmMISRoutine.ChkListBoxRoutines.Items
LogtoSet1.Add(Item)
Next

For Each Item As Object In LogtoSet1
....do stuff
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies

P: n/a
marcmc wrote:
frmMISRoutine is the 3rd form in myApp.
the following code is in the 2nd form of myApp.
I don't get any errors but it never builds the array list.
Can you access another foprms control in this way.
I have accessed variables thru setReceive etc but have not tried to access
an actual control.

Dim LogtoSet1 As New ArrayList
Dim frmMISRoutine As New Routines

For Each Item As Object In frmMISRoutine.ChkListBoxRoutines.Items
LogtoSet1.Add(Item)
Next

For Each Item As Object In LogtoSet1
...do stuff


Yes you can access items like this from another form, although I think
OO guys would look down on it a little.

I assume you have make ChkListBoxRoutines a public control. If that's
the case then the reason that the array is never built is because
ChkListBoxRoutines.items is empty. do:

Debug.Writeline(frmMISRoutine.ChkListBoxRoutines.C ount)

to check it. My guess would be that you are adding items to that
collection in the Form_Load or something like that. The form_load event
doesn't fire until you show the form so you should load up the items in
the Sub New function if you want them available right away.

Also, a better way to write this is probably to make a public readonly
property in frmMISRoutine that returns the arraylist you are looking
for. Better OO form.

hope this helps
Chris

Nov 21 '05 #2

P: n/a
"marcmc" <ma****@discussions.microsoft.com> wrote in message
news:CD**********************************@microsof t.com...
I don't get any errors but it never builds the array list. .. . . Dim frmMISRoutine As New Routines

For Each Item As Object
In frmMISRoutine.ChkListBoxRoutines.Items
LogtoSet1.Add(Item)
Next
Are you loading these Items through the Designer, or at Run-Time?
If they're /not/ in the Designed form, then they won't be in the new
instance of the Form that you are creating when you execute
Dim frmMISRoutine As New Routines


You must get hold of a reference to the form that is already loaded
and, therefore, stands a rather better chance of having some values
in it.

Regards,
Phill W.
Nov 21 '05 #3

P: n/a
Thanks Chris

"Chris" wrote:
marcmc wrote:
frmMISRoutine is the 3rd form in myApp.
the following code is in the 2nd form of myApp.
I don't get any errors but it never builds the array list.
Can you access another foprms control in this way.
I have accessed variables thru setReceive etc but have not tried to access
an actual control.

Dim LogtoSet1 As New ArrayList
Dim frmMISRoutine As New Routines

For Each Item As Object In frmMISRoutine.ChkListBoxRoutines.Items
LogtoSet1.Add(Item)
Next

For Each Item As Object In LogtoSet1
...do stuff


Yes you can access items like this from another form, although I think
OO guys would look down on it a little.

I assume you have make ChkListBoxRoutines a public control. If that's
the case then the reason that the array is never built is because
ChkListBoxRoutines.items is empty. do:

Debug.Writeline(frmMISRoutine.ChkListBoxRoutines.C ount)

to check it. My guess would be that you are adding items to that
collection in the Form_Load or something like that. The form_load event
doesn't fire until you show the form so you should load up the items in
the Sub New function if you want them available right away.

Also, a better way to write this is probably to make a public readonly
property in frmMISRoutine that returns the arraylist you are looking
for. Better OO form.

hope this helps
Chris

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.