L
Lars Black
I'm a bit puzzled about the way events are triggered on a form. Given the
code below, there seems to be a difference between using Show and
ShowDialog.
Form2 frm;
// Test ShowDialog
frm = new Form2();
frm.ShowDialog();
frm.Visible = false;
frm.ShowDialog();
frm.Dispose();
// Test Show
frm = new Form2();
frm.Show();
frm.Visible = false;
frm.Show();
I've put logging in all the eventhandlers (not a messagebox that removes
focus), and here's the result:
ShowDialog:
Activated
GotFocus
Load
Deactivated
LostFocus
Load <==== **** Why this one??
Activated
GotFocus
Show:
Activated
GotFocus
Load
Deactivated
LostFocus
Activated
GotFocus
LostFocus
Why is Load called twice in the ShowDialog example? The help says "Occurs
before a form is displayed for the first time", but it obvious also fires
when the form is show the second time...
Is this a bug?
Cheers,
Lars
code below, there seems to be a difference between using Show and
ShowDialog.
Form2 frm;
// Test ShowDialog
frm = new Form2();
frm.ShowDialog();
frm.Visible = false;
frm.ShowDialog();
frm.Dispose();
// Test Show
frm = new Form2();
frm.Show();
frm.Visible = false;
frm.Show();
I've put logging in all the eventhandlers (not a messagebox that removes
focus), and here's the result:
ShowDialog:
Activated
GotFocus
Load
Deactivated
LostFocus
Load <==== **** Why this one??
Activated
GotFocus
Show:
Activated
GotFocus
Load
Deactivated
LostFocus
Activated
GotFocus
LostFocus
Why is Load called twice in the ShowDialog example? The help says "Occurs
before a form is displayed for the first time", but it obvious also fires
when the form is show the second time...
Is this a bug?
Cheers,
Lars