Well Load event occurs before a form is displayed for the first time.
As there are other Form events that may be useful, try to check this condition before the frmEntrySecretKey.Show() method is called. If this is your "first form" check the Program.cs and modify it in a proper way. If there is something that you are not clear, improve this question.
Some references:
Form events
http://msdn.microsoft.com/en-us/library/td1s43eb.aspx[
^]
UPDATE:
Based on your comment, this is what you should try.
Open a file in your project called Program.cs
Inside you should find something like
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmEntrySecretKey());
}
}
And try to change it in
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
string sk = BllLoginHelper.checkSecretKeys();
if (sk == null)
{
Application.Run(new frmLogin());
}
else
{
Application.Run(new frmEntrySecretKey());
}
}
}
It is not an elegant solution but it will do your job. In this way you will be able to proceed and then in the future search for a more elegant solution.
Cheers!