I need a user to select the file to open before they can use the main form in the program I am writing. I wrote the following in a form load event handler:
private void MainForm_Load(object sender, EventArgs e)
{
if (openXmlFileDialog.ShowDialog() != DialogResult.OK)
Application.Exit();
fileName = openXmlFileDialog.FileName;
Activate();
}
After that, MainForm appears in the background, despite the call to the Activate () function on it.
Another problem is that if the user clicks Cancel and Application.Exit () is called, this does not affect.
source
share