显示多个表单 [英] Showing multiple forms
问题描述
在我的代码中,我有一个主窗体(名为 frmMain)和一个关于框(名为 AboutBox1).我想要发生的是当用户单击菜单条中的帮助菜单,然后单击关于我希望显示 AboutBox1 表单时.我已经研究过如何做到这一点,但是当我尝试输入时,智能感知无法识别第二种形式,我不知道为什么.有什么想法吗?
In my code I have a main form (named frmMain) and an About Box(named AboutBox1). What I want to happen is when the user clicks on the Help menu in my menu strip and then clicks on About I want the AboutBox1 form to show. I've researched on how to do it but the intellisense is not recognizing the second form when I try and type and I have no idea why. Any ideas?
我假设我放在菜单按钮点击的代码是:
The code that I'd assume that I put in my menu button click even is:
AboutBox1 aboutbox = new aboutbox();
aboutbox.ShowDialog();
然而,AboutBox1 给出了找不到类型或命名空间的错误.
however AboutBox1 gives an error that the type or namespace could not be found.
这是我目前拥有的代码.随之而来的还有一个新创建的表单,其中只有初始代码:
Here is the code I currently have. Along with this is also a newly created form that has nothing but the initial code in it:
https://gist.github.com/anonymous/5366535
推荐答案
试试这个:
AboutBox1 aboutbox = new AboutBox1();
aboutbox.ShowDialog();
ShowDialog()
创建模态窗口,如果需要创建非模态窗口可以使用 Show()
方法.
ShowDialog()
creates a modal window, if you need to create a modeless window you can use Show()
method.
在 C# 中
初始化对象的典型方法是
the typical way to initialize a object is
Classname variable_name = new Classname(); // assuming that constructor does not take any parameter
<小时>
阅读本文一次:对象(C# 编程指南)
它将帮助你理解一些基本的东西.
Go though this article once : Objects (C# Programming Guide)
it will help you to understand a few basic things.
这篇关于显示多个表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!