I have a C# program that when the operator needs to scan out of a project, they press the Scan_Button on the main screen. This brings up a modal dialog box to enter their scan out data. Occasionally, after the close the dialog box, the focus is lost to the main screen (looking like the program has locked up).
Here is the Main Program that opens the dialog box.
private void Scan_Button_Click(object sender, EventArgs e)
{
Main_Program_Scan Scan = new User_Program_Scan();
MainProgram.Enabled = false;
if (Scan.ShowDialog(this) == DialogResult.Yes)
{
ScanComputer = "Yes";
}
else if (Scan.DialogResult == DialogResult.No)
{
ScanComputer = "No";
}
}
Here is the main parts of the dialog box program.
public partial class User_Program_Scan : Form
{
Main_Program Owner = null;
public Main_Program_Scan()
{
InitializeComponent();
this.ShowInTaskbar = false;
Completed_Button.DialogResult = DialogResult.Yes;
Cancel_Button.DialogResult = DialogResult.No;
}
private void Completed_Button_Click(object sender, EventArgs e)
{
Main_Program.MainProgram.Enabled = true;
this.Close();
}
}
I have tried taking out the MainProgram.Enabled = false;
in case the dialog box closes somehow without setting MainProgram.Enabled = true;
but I havent been able to run it for any length of time, yet.
I’m thinking that there is something else that I am missing.
1