Accessing properties of Controls in another Form

G

Guest

I have 2 forms (Form1 and Form2) in my C# project. I created the second form
from the main form like so:

Fom2 aForm = new Form2();
aForm.ShowDialog();

How do I access the properties of a control (label1) in Form1 from Form2?

Thanks
Andrew
 
R

RCS

I'd say you shouldn't directly manipulate controls on another form, but if
you need to - you could also do something like this:

from form2:

((Label)parent.Controls.Find("label1",true)[0]).Text = "Hello there";
 

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