on load isn't executed

  • Thread starter Håvard Olerud Eriksen
  • Start date
H

Håvard Olerud Eriksen

I've got a WinForm MDI application. A little while ago (probably after I
made some changes) my Load method for the form stopped being executed. I had
some initialization done there and I suddenly noticed that this wasn't done
anymore. I haven't been able to get it to work again and have had to move my
code to OnShown instead. Does anyone have an idea why this is happening? All
I've got there now is a MessageBox.Show but this doesn't show.
The application has been written using VS 2008, C#

Thanks in advance,
Håvard
 
H

harborsparrow

I've got a WinForm MDI application. A little while ago (probably after I
made some changes) my Load method for the form stopped being executed. I had
some initialization done there and I suddenly noticed that this wasn't done
anymore. I haven't been able to get it to work again and have had to move my
code to OnShown instead. Does anyone have an idea why this is happening? All
I've got there now is a MessageBox.Show but this doesn't show.
The application has been written using VS 2008, C#

Thanks in advance,
Håvard

Hi -

You should be able to see where the Load's handler (method) gets
registered in the "hidden" code within the page's Designer.cs file.
Search on += and if it's missing, you can add it back by hand (look at
one of the other += statements in the designed to see the syntax).
Also, in VS 2005, you can register an event in the Window Designer by
selecting (in the properties window pane) the lightning bolt icon. I
don't know if that's still there in 2008 or not.
 
H

Håvard Olerud Eriksen

Cor Ligthert said:
Havard,

You know that On Load fires only one time?

Yes, I know that but it doesn't seem to be fired at all. If it had my single
MessageBox.Show() would be shown wouldn't it? What I'm doing is that I'm
showing a login window in the constructor of the mdi form (main form). If
invalid login credentials are entered or the user clicks cancel I want to
shut down the application. This worked previously when my Load fired
properly but now that I'm using the same code in OnShown there's a "flash"
of the main window before it closes (for obvious reasons) and I want to
avoid that. If you have any other, better ideas on how to solve this, I'm
all ears :)

Håvard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top