Groups | Blog | Home
all groups > c# > august 2003 >

c# : Simple forms question


Marcellus
8/8/2003 6:58:37 AM
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.




[quoted text, click to view]
JSM
8/8/2003 11:27:01 PM
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

Arran Pearce
8/11/2003 9:29:19 AM
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.


[quoted text, click to view]

AddThis Social Bookmark Button