c# - Switching forms in .NET compact framework (windows mobile 6) -


I'm new to .NET Compact Structure (and much new for C #) and I'm in a mobile app At the high level of problem with the switching form, my application uses several main forms, in which there is a main "App Manager" class which navigates / switch between forms. My plan is to create forms on demand, cache them and A simple hide / show strategy Was using.

First of all, I wanted to do something like the following in my main application class:

  Public zero switch form (form newform) {currentForm.Hide (); // instance member newForm.Show (); CurrentForm = newForm; }  

However, it does not work in a planned way. The new look that I was trying to show appeared very temporarily and then disappeared behind the main aspect of my application - any idea about why this is happening? I have read a lot on form switching, and most places mention that the above method was the way to do this.

I then tried the following:

  Public Zero Switch Form (Form Newform) {currentForm.Hide (); // example member currentForm = newForm; NewForm.ShowDialog (); }  

And it seems to do the trick. I am thinking, is this the right way to go about it? Using the Shoddyog () method, however, is another problem. It is said that I want to settle the old form, like:

  Public zero switch form (form newform) {form old form = present form; CurrentForm = newForm; NewForm.ShowDialog (); OldForm.Dispose (); }  

I then found out that oldform.Dispose () code does not execute until newForm.ShowDialog () is completed (form is closed). Therefore, the above forms can not be correctly handled, because in the form of method it is called again when moving forward in new forms. Another way is to settle the old form before showing the new one, even then, my application temporarily renders something else (which is behind any form) between the settlement of the old form. New translation is done: / How should someone go?

Try:

< Code> Public Zero Switch Form (Form Newform) {form oldform = current form newF Orm.Show (); CurrentForm.Hide (); CurrentForm = newForm; OldForm.Dispose (); }

Comments