在visual c ++中显示两种形式 [英] showing two forms in visual c++

查看:82
本文介绍了在visual c ++中显示两种形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的visual c ++ windows窗体应用程序,目前这个项目中只有一个窗体表示FormA是FormA,我想将另一个FormB形式添加到当前项目中。



现在需要在FormA上有一个标题为Show FormB的按钮。

点击此按钮后,FormB应该对用户可见,并且

FormA应该被禁用,

当用户关闭FormB时, FormA应该再次供用户使用,

在FormB上还有一些与Sql-Lite数据库的交互。



任何想法/解决方案热烈欢迎。





谢谢



问题由Jibesh重新安排为可读性[/编辑]

I have a simple visual c++ windows forms application, at the moment there is only one form in this project say the form is FormA, i want to add another form FormB to the current project.

Now it is required that there is a button titled as "Show FormB" on FormA.
Upon clicking this button the FormB should be visible to the user and
FormA should be disabled,
Next when the user closes the FormB, FormA should be available to the user again,
On FormB there is also some interaction with Sql-Lite database.

Any ideas/solutions will be welcomed warmly.


Thanks

question rearranged for readability by Jibesh[/Edit]

推荐答案

这是一个非常糟糕的主意。看起来你想要显示一些表单序列,一次一个,就像向导一样。它可能是别的东西。在任何情况下,只使用一个表单,只需替换它的内容。



它是最简单的形式,它将有一组<$ c $的实例c> Panel 填写整个表单,并填充您最初计划在每个表单上拥有的控件。因此,面板将代表表单内容。一次只显示一个表单,隐藏所有其他表单。从一个表单移动到另一个表单(例如,下一步)将隐藏可见面板并显示另一个表单。你可以设计任何更复杂的场景。



-SA
This is a really bad idea. It looks like you want to show some sequence of forms, one at a time, like with a wizard. It can be something else. In any case, use only one form, just replace its content.

It the simplest form of it, it would be having a set of instanced of Panel filling the whole form and populated with controls you initially planned to have on each form. So a panel will represent a form content. Show only one form at a time, hide all others. Moving from one form to another one (for example, "Next") will be just hiding a visible panel and showing another one. You can design any more complex scenario.

—SA


这不是那个很难按照你在代码中解释的步骤。



如果你从FormA显示你的FormB作为模态对话框{Form.ShowDialog()},



只需使FormA.Visible = false;

使用ShowDialog显示你的FormB

当你完成Form

然后调用FormA.Visible = true;



您还可以通过其他方式管理此UI行为。由您决定并选择最适合您的。
It''s not that tough to follow the steps you explained into code.

If you are displaying your FormB as Modal dialog { Form.ShowDialog() } from FormA,

just make the FormA.Visible = false;
Display Your FormB using ShowDialog
when you are done with Form
then call FormA.Visible = true;

There are other ways you can manage this UI behaviour. Its up to you and to choose whats best for you.


这篇关于在visual c ++中显示两种形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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