Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Compact Framework / January 2006

Tip: Looking for answers? Try searching our database.

MyForm.Show not working in CF2.0

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David D Webb - 30 Jan 2006 03:42 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.