从MenuStrip打开表单 [英] Open a form from a MenuStrip

查看:110
本文介绍了从MenuStrip打开表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!



我试图在我的解决方案资源管理器中打开一个表格我有2个表格

Form1 =主窗体

Form2 =我在菜单条中按(选项)时尝试弹出的那个

但是当我尝试在我的代码中声明Form2时不想出现



Hello there!

I am trying to open a form inside of a form I have 2 forms in my Solution Explorer
Form1 = main form
Form2 = the one I try to make pop up when pressing (Options) in the menu strip
but when I try to declare the Form2 in my code it doesnt want to show up

Form2.Show();





不想工作,抱歉缺乏信息。匆忙,只是寻找快速修复。有小费吗?如果您需要更多信息,请告诉我。



doesnt want to to work, sorry for lack of information. In a hurry, just looking for quick fixes. any tips? If you need any more information please do tell me.

推荐答案

MenuStrip?

双击某个项目,只需添加以下代码: br />
MenuStrip?
Double click on a item and simply add this code:
Form2 nForm = new Form2();
nForm.TopLevel = false;
nForm.Show();


假设'Form1是您的主窗体:
Assuming 'Form1 is your Main Form:
private Form2 form2 = new Form2();

private void Form1_Load(object sender, EventArgs e)
{
    form2.Show();
}

当然,这是猜测你未能创建'Form2 to'Exp的实例;但是,不创建实例是C#新手的常见错误。

Of course, this is a guess that you have failed to create an instance of 'Form2 to 'Show; however, not creating instances is a frequent mistake of people new to C#.


这篇关于从MenuStrip打开表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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