Hi all,
I am trying to create a dead simple windows forms app - something I hardly ever do. All I need it to do is popup with a file dialog when it starts, and after the use chooses a file, then open the main form. I do this in the form constructor.....It all works, but when it runs, after you choose the file from the dialog, the focus for the main form is lost
I tried Form.ActiveForm.Focus(), but in the constructor that property returns null..... Do any of you windows forms experts have the answer?
Heres my code:
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
if (fileName.Length < 1)
{
OpenFileDialog openDialog = Form1.GetFileName();
DialogResult result = openDialog.ShowDialog(null);
if(result != DialogResult.OK)
{
return;
}
fileName = openDialog.FileName;
}
}