Hello Community
I have a Windows program that has 2 forms that appear on one screen at the same time, each occupying half of the screen.
The forms each have their own DatagridViews and their accompanying toolbars.
I can close both forms at the same time by clicking the Close button (there is only one close button on the screen
which is used for both forms) the Close button executes the code behind. The way that the button closes both forms is
that the "Close" button resides on one form and that button only needs to execute the instruction "Close()" to close that form
but for the second form on the screen to close, that form name has to be attached to the Close() command to close it
as shown below:
FormTwo FormTwo2 = (FormTwo)Application.OpenForms["FormTwo"];
FormTwo2.Close();
Close();
But the problem is that there is a DataGridView on each form with their own accompanying toolbars and I want to save the data that gets
entered into both DataGridViews at the same time programmatically when the "Close" button gets clicked by executing both of the
forms BindingNavigatorSaveItem_Click events. But only the data in Form1 BindingNavigatorSaveItem_Click event gets executed when I click the Close
button. The data in the DataGridView on the second form does not get saved when the code to execute the BindingNavigatorSaveItem_Click event
for the second form executes. Instead, when the command to execute the BindingNavigatorSaveItem_Click event in the second form (FormTwo) executes
the program just hangs. Below is the code that executes the BindingNavigatorSaveItem_Click on the second form (FormTwo):
FromOneBindingNavigatorSaveItem_Click(sender, e);
FormTwo2.FormTwoBindingNavigatorSaveItem_Click(sender, e);
The entire program in Close button event looks something like this:
FromOneBindingNavigatorSaveItem_Click(sender, e);
FormTwo FormTwo2 = (FormTwo)Application.OpenForms["FormTwo"];
FormTwo2.FormTwoBindingNavigatorSaveItem_Click(sender, e);
FormTwo2.Close();
Close();
In other words the first BindingNavigatorSaveItem_Click event that is on
FromOne and where the Close button event resides executes but FormTwo
BindingNavigatorSaveItem_Click event that resides on the second form where there
is no "Close" button doesn't execute.
The question is how do I execute the BindingNavigatorSaveItem_Click event
in FormTwo from FormOne?
Thank you
Shabeaut