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
Ginny Caughey [MVP] - 30 Jan 2006 15:19 GMT
David,
If you use the Singleton pattern described here
http://www.c-sharpcorner.com/UploadFile/susanabraham/CreationalPatterns060420050
50058AM/CreationalPatterns.aspx?ArticleID=f117f4e7-933b-4072-922a-d0774dc297fd
then you can easily reference and reuse any forms in your app like this:
LoginForm lf = LoginForm.Instance();
lf:Show(); //or lf.ShowDialog();

Signature
Ginny Caughey
.NET Compact Framework MVP
> I'm converting a CF1 project to a CF2 project.
>
[quoted text clipped - 26 lines]
>
> Dave
David D Webb - 31 Jan 2006 04:34 GMT
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
> David,
>
[quoted text clipped - 35 lines]
>>
>> Dave
Ginny Caughey [MVP] - 31 Jan 2006 12:57 GMT
David,
What is the problem with that approach?

Signature
Ginny Caughey
.NET Compact Framework MVP
> 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
[quoted text clipped - 42 lines]
>>>
>>> Dave
David D Webb - 31 Jan 2006 22:16 GMT
Because it doesn't work in CF2.0. Apparently you can't show a form from the
load method of another form.
-Dave
> David,
>
[quoted text clipped - 46 lines]
>>>>
>>>> Dave
Ginny Caughey [MVP] - 31 Jan 2006 22:37 GMT
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.

Signature
Ginny Caughey
.NET Compact Framework MVP
> Because it doesn't work in CF2.0. Apparently you can't show a form from
> the load method of another form.
[quoted text clipped - 52 lines]
>>>>>
>>>>> Dave
davecline - 31 Jan 2006 19:03 GMT
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
David D Webb - 31 Jan 2006 22:19 GMT
Thanks, I'll give that a try.
-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
[quoted text clipped - 9 lines]
> Regards,
> Dave Cline