Hi,
Here is a possible solution:
You need 2 forms:
- MainForm (IsMdiContainer = True)
- LogonForm (optionally: ControlBox = False; FormBorderStyle = FixedSingle; MaximizeBox = False)
In the LogonForm create a method that checks the validity of the credentials passed. If the credentials are good, set the DialogResult of the form to OK.
this.DialogResult = DialogResult.OK;
In the Program.cs set the following:
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(fals e);
LogonForm frm = new LogonForm();
DialogResult result = frm.ShowDialog();
if (result == DialogResult.OK)
Application.Run(new MainForm());
}
This way, your logonform is first opened and only if the user entered valid credentials, the mainform (mdi) is opened.
Greetz,
Geert
http://geertverhoeven.blogspot.com