/// <summary> /// Save the current file. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SaveClick(object sender, EventArgs e) { // If there is MdiChildren. if (this.MdiChildren.Length > 0) { // If the child is notepad negative. if (this.ActiveMdiChild.GetType() == typeof(formNotepadNegative)) { // Call the SaveClick function. formNotepadNegative notepadNegativeInstance = (formNotepadNegative)this.ActiveMdiChild; notepadNegativeInstance.SaveClick(sender, e); } // If the child is Customer Entry. else if (this.ActiveMdiChild.GetType() == typeof(formCustomerEntry)) { // Call the ButtonSaveClick function. formCustomerEntry customerEntryInstance = (formCustomerEntry)this.ActiveMdiChild; customerEntryInstance.ButtonSaveClick(sender, e); } else { // Show a message box if the form is not supported in the current window. MessageBox.Show("The 'Save' operation is not supported by the current selected windows.", "Operation Not Supported"); } } else { // Show a message box if there is no form open. MessageBox.Show("You must open a form in order to use the 'Save' operation.", "Operation Not Supported"); } }
/// <summary> /// This assigns an instance of the customer entry form. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void WindowOpenCustomerEntry(object sender, EventArgs e) { // Create (or call) the customer entry instance. formCustomerEntry customerEntryInstance = formCustomerEntry.Instance; // Assign this child window an MdiParent customerEntryInstance.MdiParent = this; // Display the existing or created instance. customerEntryInstance.Show(); customerEntryInstance.Focus(); }