I had a problem after adding this code, so I can access the MainWindow elements in the Downloader class:
public partial class MainWindow : Form { private Downloader fileDownloader; public MainWindow() { InitializeComponent(); fileDownloader = new Downloader(this); }
and
class Downloader : MainWindow { private MainWindow _controlsRef; public Downloader(MainWindow _controlsRef) { this._controlsRef = _controlsRef; }
now it gives me a "Unhandled exception like" System.StackOverflowException "occurred in System.Windows.Forms.dll" in the line
this.mainControlPanel.ResumeLayout(false);
in MainWindow.Designer.cs. If I comment on the code above, it works fine. Any ideas please?
PS. Also, when I am in the Downloader class, I have to access controls like
textbox.Text
or
_controlsRef.textbox.Text
Both don't seem to compile errors, is there any difference between the two?
source share