Simple forms question

J

JSM

Hi,

I have a form (FormA) which was loaded using Application.Run when my app
loads. This form has a button which loads Form B using "FormB myForm=new
FormB()". My question is, how do I access and modify the value of a control
on FormA from FormB?

I thought this would be easy but I was wrong.

Cheers,

John
 
M

Marcellus

Expose a public property of type Form, from B. Assign A
to the public property. Then B has a reference to A, you
can iterate the controls collection to identify your
target control and manipulate it as you wish.
I'm sure there's a more elegant solution, but this will
work in the interim.
 
J

JSM

Hi Mikael,

The example you gave sends information from A to B. What I can't figure out
is how can I send information from B to A. Since A was created using
Application.Run I don't have an instance name of A which I could use.

Cheers,

John
 
A

Arran Pearce

if in FormB's constructor you have a param which receieves a referance of a
form control.

then when you call FormB from FormA use the this keyword to pass the
referance.

FormB will then be able to access public elements in FormA.
 

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