MyForm.Show not working in CF2.0

  • Thread starter Thread starter David D Webb
  • Start date Start date
D

David D Webb

I'm converting a CF1 project to a CF2 project.

I call the code:

(new LoginForm()).Show();

from the Load method of another form (the main form in the app). I read in
another post that this no longer worked in CF2.0, but it didn't mention how
to get around this. When the app starts, it loads the main form, but
immediately throws up a login form. For various reasons, I didn't make the
login form the main form.

Also I have another instance where the form is no longer showing. I call
this from a menu click event and it never shows the form:

PlannerDownloadForm plannerDownloadForm = new PlannerDownloadForm();

plannerDownloadForm.ShowDialog();

The Load method of PlannerDownloadForm begins a download process, then
closes itself as the last line.

Any suggestions, or suggested further reading would be appreciated.

Should I move the code to a Paint or Activated event and keep track of a
bool so it only does it once?

Thanks,

Dave
 
Thanks, but I don't think that would change anything in my situation. I
would still need to call that code from the Load method of the primary
form - which would still not work, since that is just a round about way of
creating an instance of the form then showing it.

-Dave
 
I don't know if there is a better way to do this - but every one of my
forms requires data to be loaded. So I put a timer on each form and
start the timer inside Form_OnLoad.
Then in the timer's Tick event I turn it off and load my data. This way
the form completely paints and looks right before I start any lengthy
operation on data or network connectivity.

What works well using this approach is if I dirty the data or need a
data refresh I just turn the timer back on. Timer ticks and the data
reloads.

Regards,
Dave Cline
 
Because it doesn't work in CF2.0. Apparently you can't show a form from the
load method of another form.

-Dave
 
Dave,

I just created a very simple app with 2 forms and was able to show the
second form from the first form's Load event handler. Maybe that's not a
great idea in general, but it did work for me. I used ShowDialog for the
second form if that makes a difference.
 
Dave,

Try ShowDialog for the second form rather than Show. This seems to work in
my simple test, but Show doesn't.
 
Back
Top