Simple forms question

  • Thread starter Thread starter JSM
  • Start date Start date
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
 
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.
 
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
 
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.
 
Back
Top