.net - C# Use instance of a class made in Form 1 in Form 2 -
I want to use an example made in Form 1 in a square form 2 a list of simplicity (i Change in example code:.
Not only this, I want to be able to modify Form 2 (clear it at some point), I got the advice I got, although it was because of how I "No spoonfeeding was told permission"
name space automationControls.FileTime {public class Form_Main: for In & out {public listing lt; String & gt; folderList; // & LT; ---- I want to use this ..... private void button_showForm2_Click (object sender, EventArgs e) {Form_Log ConfirmBoxForm = new Form_Log (this); ConfirmBoxForm.Show ();}} // form_Main opens form_Log namespace automationControls.FileTime {public partial class Form_Log: form {public Form_Log (form_Main _f1) {InitializeComponent ();} private void Form1_FormClosing (object sender, FormClosingEventArgs e) {How.Do.I.AccessForm_Main.folderList.Clear (); // & LT; ---- ............ in this function}}} Answered: In the manufacturer of Form_Log, you can store the reference store somewhere _f1 in Form_Log can access from anywhere
Why do you not use the constructor you have already added your form have taken?
personal formamine_manform; Public form_log (formamen_f1) {initial group (); _manform = _f1; } Private Zero Form 1_formclosing (Object Sender, FormClosingEventArgs e) {var myList = _mainForm.folderList; }
Comments
Post a Comment