适用于许多获胜形式的环境 [英] works with many win form environment

查看:43
本文介绍了适用于许多获胜形式的环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

示例:项目具有三种形式:Form1,Form2,Form3.我站在form1上创建form2的1个对象.为该平台创建了form2,如果不关闭form2,则无法关闭Form1.问题是有一种方法可以暂时禁用或隐藏Form1.如果我们使用visible方法,那么它只会在任务栏下方最小化,许多打开的表单都会被堆积,表单编号与激活数量一样多.我应该怎么办?我听说,如果他们确实解决了MDI表单,他只有两种方法:由于MDI或简单表单始终是

example : project has three forms: Form1, Form2,Form3. I stand at form1 create 1 object of form2. form2 is created for that platform, can not close Form1 without closing form2. Question is there a way to disable or hide away temporarily Form1. If we use methods visible , then it''s only minimized below the taskbar,much form we open more forms will bw piled, the form number as much as our activation. What should I do? I heard that if they do solve the MDI form, his only two ways: as MDI or simple form is always

推荐答案

不要使用很多表单,最不好.不要使用MDI,这是非常不鼓励的(即使是Microsoft也不建议这样做),并且对每个人都非常不便.这是最简单的使用方法:选项卡式界面.使用控件System.Windows.Forms.TabControl.您可以使用Designer或在运行时向其中添加任意数量的选项卡.您在每个表格放置的内容中都有一个单独的选项卡.


如果您需要先登录,请执行以下操作.再创建一个登录表单.首先以调用System.Windows.Forms.Form.ShowDialog的模式形式显示它.成功登录后,此表单将关闭,不再需要.如果无法登录,请使用System.Windows.Forms.Application.Exit返回模态对话框后退出应用程序.这将是最佳解决方案.
[END EDIT1]


再次考虑:您有两种形式:1)登录表单,2)多选项卡表单.
运行入口点时,请使用多选项卡"表单运行System.Windows.Forms.Application表单,使用登录表单运行.这将使多选项卡"表单成为主要表单.变体1:在您的入口点方法中,使用Application.Run之前的登录表单调用System.Windows.Forms.Form.ShowDialog.如果登录不成功,请退出,所以将永远不会调用Application.Run.方案2:处理主窗体的事件Shown,以使用登录窗体调用System.Windows.Forms.Form.ShowDialog.如果登录成功,则继续;否则,请继续.如果不是,请与处理程序一起调用System.Windows.Forms.Application.Exit(它可以工作).非常简单.
[END EDIT2]


请参阅我的表单和讨论之间的协作解决方案:
如何在列表框之间复制所有项目两种形式 [ ^ ].
[END EDIT3]

这很容易.

—SA
Do not use many forms, it''s the worst. Do not use MDI, this is highly discourages (even by Microsoft) and very inconvenient to everyone. Here is the simplest thing to use: Tabbed interface. Use the control System.Windows.Forms.TabControl. You can add any number of tabs to it, with Designer or during run-time. What you had in the content of each form put is a separate tab.


If you need a log in first, do the following. Create one more form for log in. In the very beginning show it in a modal form calling System.Windows.Forms.Form.ShowDialog. After successful log in, this form will be closed and never needed again. In case of failure to log in, exit application after the modal dialog is returned with System.Windows.Forms.Application.Exit. This will be the optimal solution.
[END EDIT1]


Consider again: you have two forms: 1) Log in form, 2) Multi-tab form.
When you run your entry point, run System.Windows.Forms.Application form with Multi-tab form, not with login form. It will make your Multi-tab form the main one. Variant #1: in your entry-point method, call System.Windows.Forms.Form.ShowDialog with the log-in form before Application.Run. If the log in is not successful, just exit, so Application.Run will be never called. Variant #2: Handle the event Shown of the main form to call System.Windows.Forms.Form.ShowDialog with the log-in form. If log in is successful, just continue; if not — call System.Windows.Forms.Application.Exit right withing the handler (it works). Quite simple.
[END EDIT2]


See my solution of collaboration between forms and the discussions:
How to copy all the items between listboxes in two forms[^].
[END EDIT3]

This is easy.

—SA


为什么需要Form1?如果您只是根据环境加载特定的表单,请在启动代码中执行此操作,然后根据您的要求运行Form2或Form3.
Why do you need Form1? If you are just loading a specific form depending on your environment then do this in your start-up code, and run either Form2 or Form3 depending on your requirements.


您不了解我的追求.
使用选项卡控件不能解决我的问题.因为我想在一开始就打开登录表单.那么,如果用户使用正确的用户名和密码登录,您将被发送到下一张表格,该表格向您介绍您想要进行哪些交易?所以你选择想要然后下一个...
如果使用选项卡控件,则可以在不检查用户名和密码的情况下访问form2.我想先检查!我认为制表符控件不合适.
注意:赢得表单项目
you don''t understand my quest.
using tab control doesn''t solve my problems. because i want openning log-in form at the beginning. then if user log in with the right user name and password you will be sent to the next form which introduce you what transaction you want? so you choose want and next ...
if you use tab control , you can access form2 without check the user name and password. i want to check first! i think tab control doesn''t suitable.
Notes : win form project


这篇关于适用于许多获胜形式的环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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