如何在Windows Mobile应用程序中关闭当前运行的窗体. [英] how to close current running form in windows mobile application.

查看:60
本文介绍了如何在Windows Mobile应用程序中关闭当前运行的窗体.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在导航一个Form(Form1)到另一个Form(Form2)时关闭当前正在运行的Form(Form1),在Form Navigation(Form2显示)之后,我必须在Form(Form1)中关闭第一个Form(form1).

我尝试过,但可能无法解决.
不像为Forms创建对象
第二种形式
Form1 f1 = new Form1();
f1.close();
如果我在Form2构造函数中为Form1创建对象,则总共加载了form1,性能不好,在没有对象创建的情况下,存在任何其他方法.
而不是this.close()方法.
此问题的任何其他解决方案

How to close current running Form(Form1)while navigating one Form(Form1)to another Form(Form2),after Form navigation(Form2 show) I have to close first Form(form1) with in the Form(Form1).

I tried it but I may not get the solution.
Not like object creations for Forms
In second form
Form1 f1=new Form1();
f1.close();
If I create Object for Form1 in Form2 Constructor,Total form1 is loaded,Performance wise it is not good,With out object creation any other method is there.
and not this.close() method.
Any other solution for this problem

推荐答案

您的问题尚不清楚.

1.我尝试过但是可能无法解决问题"的含义.是什么意思?发生什么事了?
2.在第二个表格Form2中,各行:
Your question is not clear.

1. What does "I tried it but I may not get the solution." mean, exactly? What happened?
2. In your second Form Form2, the lines:
Form1 f1=new Form1();
f1.close();


完全按照您告诉他们的方式去做.第一行创建Form1的新实例(正如您认为的那样,它没有引用原始Form1).第二个只是关闭这个新实例.

如果Form1是应用程序启动时加载的第一个表单,则无法将其关闭.如果这样做,那么该应用程序也将关闭,因为当第一个Form关闭时,程序流将返回到调用它的方法并在此继续.可以,但是对Form1的调用是最后一条语句,因此无需执行其他操作,应用程序将关闭.

如果您为控件(Forms)使用了明智的名称,那么整个事情将更容易讨论.例如,给他们命名代表他们所做的事情.如果要输入地址,可以将Form1重命名为"MainForm",将Form2重命名为"AddressForm".

但是,我怀疑您要尝试执行的操作是先拥有一个登录表单,然后再拥有一个主表单,在这种情况下,它们应该是Form1作为"LoginForm",Form2作为"MainForm".如果这是正确的,那么首先,您应该在询问之前在该论坛中搜索登录表格"(您会找到很多答案),其次,您应该在问题中对其进行适当的描述.

如果这是登录表单问题,请按照登录表单 [


do exactly what you are telling them to do. The first line creates a new instance of Form1 (it does not reference the original Form1, as you seem to think). The second one simply closes this new instance.

If Form1 is the first form that loads when your application starts then you cannot close it. If you do, then the application also closes because when the first Form closes program flow returns to the method that called it and continues there. This would be fine but the call to Form1 is the last statement so there''s nothing else to do and the app closes.

This whole thing would be easier to discuss if you used sensible names for your controls (Forms). For example give them names that represent what they do. Form1 could be renamed to ''MainForm'' and Form2 as ''AddressForm'', if it was for entering addresses.

However, what I suspect that you are trying to do is have a login form and then a main form, in which case they should be Form1 as ''LoginForm'' and Form2 as ''MainForm''. If this is correct then, firstly you should have searched this forum for "login form" before asking (you would have found loads of answers) and secondly you should have described it properly in your question.

If this is a Login Form problem then follow the links in Login form [^].


这篇关于如何在Windows Mobile应用程序中关闭当前运行的窗体.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆