Groups | Blog | Home
all groups > dotnet compact framework > october 2004 >

dotnet compact framework : Application with 3 Forms


Darren Shaffer
10/7/2004 9:41:46 AM
Bruno,

If you make your forms singletons, you can improve performance and control
navigation. Example:

public class Foo : System.Windows.Forms.Form
{
private static Foo instance; // singleton

public static Foo GetInstance()
{
if ( instance == null )
{
instance = new Foo();
}
return instance;
}

So now you can write code like this:

Foo.GetInstance().Show();

-Darren


[quoted text, click to view]

Tim Wilson
10/7/2004 11:41:05 AM
With the 3 forms, what are you trying to accomplish overall? It might be
easier to make suggestions if we know the relationship(s) between these
forms.

--
Tim Wilson
..Net Compact Framework MVP

[quoted text, click to view]

Bruno Spirig
10/7/2004 4:30:38 PM
Hello

I have an application with 3 windows forms: Form1, Form2, Form3, where Form1
is the
startup form.
Form 1 call Form 2, Form 2 call Form 3, Form 3 should call Form 1.
With 'this.Close()' step-by-step work this, but it's not really clean and it
looks not fine.
How can i jump direct from Form3 to Form 1?
Or otherwise: How can i make a 'global' usable Form.

Thank you for help!

Best regards,
Bruno



Darren Shaffer
10/8/2004 8:39:21 AM
Don't worry about closing Form2. Your app has 3 forms. Navigate between
them with GetInstance().Show() and don't worry about closing or hiding
previous
forms.

-Darren


[quoted text, click to view]

Bruno Spirig
10/8/2004 9:25:30 AM
Hi Darren, Hi All

I have tryed your idea, but i get an error by close the Form3:
1. I place in each Form a GetInstance function
2.Button 'Jump to Form2' in Form 1: f2.GetInstance().ShowDialog();
3.Button 'Jump to Form3' in Form 2: f3.GetInstance().ShowDialog();
4. Button 'Jump to Form1' in Form 3: f2.GetInstance.Close();
-> ERROR Argument Execption
I tryed: first Close(); and then f2.GetInstance.Close();
I tryed: first f2.GetInstance.Close()and then Close();
I tryed a lot of other things but without a success.

What make i wrong?

Best regards,
Bruno


"Bruno Spirig" <bruno.spirig@spirig-systems.ch> schrieb im Newsbeitrag
news:OJFq9pHrEHA.592@TK2MSFTNGP11.phx.gbl...
[quoted text, click to view]

Bruno Spirig
10/8/2004 5:02:13 PM
Hi Darren

My Forms must be 'locked', therefore i use ShowDialog();
With GetInstance().Show(), it works fine, but with
GetInstance().ShowDialog(), i get an error!
How can i make it with ShowDialog?

Best regards,
Bruno

"Darren Shaffer" <darrens@nospam.com> schrieb im Newsbeitrag
news:urZGaSUrEHA.2000@tk2msftngp13.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button