如何在打开另一个模态窗体之前关闭模态窗体

编程入门 行业动态 更新时间:2024-10-26 22:29:03
本文介绍了如何在打开另一个模态窗体之前关闭模态窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有三(3)个表格。 Form1是主要形式。当用户单击此表单上的按钮时,它会打开另一个模式表单(Form2),以便用户可以在文本框中输入数字。如果用户单击CANCEL,Form2将正确关闭,焦点将返回主窗体,且不会失败。如果用户在文本框中输入一个数字并单击(或按ENTER键),我希望Form2关闭(处置任何,不隐藏)和Form3打开,数据代表输入的数字。在我以模态方式打开Form3之后,我似乎无法关闭Form2。这可能吗?我理解这个问题。 Form3现在是模态的,并且专注于OVER Form2。关于这个还能做什么?我需要用户在Form2或CANCEL的文本框中输入一个数字,而不是在主窗体上尝试另一个选项。是的 - 我在网上搜索了一些类型的帮助,找不到任何有用的东西。 我尝试了什么: 我在调用打开Form3之前尝试放置Me.Close和Me.Dispose。我试过关闭并处理Form3 FROM Form3。我已经走近了关闭并处理方法。如果我不进行Form2模式,它可以正常工作,但是用户可以从主窗体中选择另一个选项,这是完全不希望的。

I have three (3) forms. Form1 is the main form. When a user clicks a button on this form, it opens another modal form (Form2) so the user can enter a number into a textbox. If the user clicks CANCEL, Form2 closes properly and focus returns to the main form without fail. If the user enters a number in the textbox and clicks (or presses ENTER), I want Form2 to close (dispose whatever, NOT HIDE) and Form3 to open with the data representative of the number entered. I cannot seem to get Form2 closed after I open Form3 modally. Is this possible? I understand the issue. Form3 is now modal and has exclusive focus OVER Form2. What can be done about this? I need the user to either a number in the textbox on Form2 or CANCEL and NOT attempt another option on the main form. YES - I have searched the web for some type of help and cannot find anything that WORKS. What I have tried: I have tried placing "Me.Close" AND "Me.Dispose" before the call to open Form3. I have tried closing and disposing Form2 FROM Form3. I have moved around the close and dispose methods. It works OK if I don't make Form2 modal, but the user can then select another option from the main form and this is totally undesired.

推荐答案

当Form2关闭时,控制权被传递回打开它的表格。 Form1负责从Form2中获取数据,处理Form2的实例,然后将数据传递给Form3。 When Form2 closes, control is passed back to the form that opened it. Form1 is responsible for grabbing the data from Form2, Disposing the instance of Form2, then passing the data to Form3.

更多推荐

如何在打开另一个模态窗体之前关闭模态窗体

本文发布于:2023-11-03 07:49:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1554610.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:窗体   模态   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!