0

I have c# project in which i have form and i want to access elements from that form from another class, how I can do this?

I tried Form1 f1 = new Form1(); and then f1.pictureBox but it's not correct, I have exception for Form1 f1 = new Form1(); saying:

An unhandled exception of type 'System.StackOverflowException' occurred in MMS-Lab1.exe
Hamid Pourjam
  • 20,441
  • 9
  • 58
  • 74
  • possible duplicate of [Best way to access a control on another form in Windows Forms?](http://stackoverflow.com/questions/8566/best-way-to-access-a-control-on-another-form-in-windows-forms) – Sam Axe Mar 08 '15 at 14:07
  • Assuming `pictureBox` is public, that's fine - it won't cause a Stack Overflow. Where is your call to `new Form1()` - is it inside `Form1`'s constructor by any chance? – James Thorpe Mar 08 '15 at 15:40

1 Answers1

0

Call new Form1() is in another class called Controller before Controller's constructor. Stack overflow is caused by Form1 f1 = new Form1(), why is that?