MSIMainForm MSImain; //instance of main form //event when a login is successful (fired by the user control) private void loginScreen_UserControl_LoginSuccess(object sender, EventArgs e) { //new instance of the main form passing the username and the parent form as parameters MSImain = new MSIMainForm(loginScreen_UserControl.UserName.ToString(), this); this.Hide(); MSImain.Show(); }
//paramterized constructor public InventoryDataForm(string file, bool newItem, MSIMainForm parent) { InitializeComponent(); MSImain = parent; fileName = file; practice = Path.GetFileNameWithoutExtension(fileName); newInventory = newItem; this.Text = "Practice: " + practice; }