我在visul c#.net 中创建了一个新的项目是windows 应用程序
我又在add new item 对话框 Tenmplates 创建了新的窗体名字叫ssia1
我在第一个代码中添加了一个mainMenu的控件
然后在第一个空间中写入 Next 我想实现他调用其他窗口的话命令该怎么写
我双击了Next在代码中写了
NextForm newForm=new ssia1Form();
可是他提示错误说找不到类型或者命名空间
是怎么一回事代码如下请高手分析:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;namespace ssia
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem menuItem4;
private System.Windows.Forms.MenuItem menuItem5;
private System.Windows.Forms.MenuItem menuItem6;
private System.Windows.Forms.MenuItem menuItem7;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null; public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.menuItem6 = new System.Windows.Forms.MenuItem();
this.menuItem7 = new System.Windows.Forms.MenuItem();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(152, 88);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(224, 21);
this.textBox1.TabIndex = 0;
this.textBox1.Text = "显示你要的数字";
//
// button1
//
this.button1.Location = new System.Drawing.Point(112, 160);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(96, 24);
this.button1.TabIndex = 1;
this.button1.Text = "开始";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(280, 160);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(96, 23);
this.button2.TabIndex = 2;
this.button2.Text = "关闭";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1,
this.menuItem4,
this.menuItem6});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem2,
this.menuItem3,
this.menuItem5,
this.menuItem7});
this.menuItem1.Text = "文件 ";
//
// menuItem2
//
this.menuItem2.Index = 0;
this.menuItem2.Text = "打开记事本";
this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
//
// menuItem3
//
this.menuItem3.Index = 1;
this.menuItem3.Text = "打开计算机";
this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
//
// menuItem4
//
this.menuItem4.Index = 1;
this.menuItem4.Text = "&Next";
this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
//
// menuItem5
//
this.menuItem5.Index = 2;
this.menuItem5.Text = "关闭";
this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click);
//
// menuItem6
//
this.menuItem6.Index = 2;
this.menuItem6.Shortcut = System.Windows.Forms.Shortcut.Alt1;
this.menuItem6.Text = "&Worker";
this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
//
// menuItem7
//
this.menuItem7.Index = 3;
this.menuItem7.Text = "&Next";
this.menuItem7.Click += new System.EventHandler(this.menuItem7_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(480, 294);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox1);
this.Menu = this.mainMenu1;
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false); }
#endregion /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
} private void button1_Click(object sender, System.EventArgs e)
{ string msg="";
Hashtable hashtable =new Hashtable();
Random rm=new Random();
for (int i=1;hashtable.Count<7;i++)
{ int ch=rm.Next(31);
if (!hashtable.ContainsValue(ch)&&ch!=0)
{ hashtable.Add(ch,ch);
msg+=ch.ToString()+"→";
textBox1.Text = msg;}
}
} private void button2_Click(object sender, System.EventArgs e)
{
this.Close();
} private void menuItem2_Click(object sender, System.EventArgs e)
{
System.Diagnostics.Process.Start("notepad.exe");
} private void menuItem3_Click(object sender, System.EventArgs e)
{System.Diagnostics.Process.Start("calc.exe");
} private void menuItem5_Click(object sender, System.EventArgs e)
{
this.Close();
} private void menuItem6_Click(object sender, System.EventArgs e)
{
} private void menuItem4_Click(object sender, System.EventArgs e)
{
} private void menuItem7_Click(object sender, System.EventArgs e)
{
Next newForm = new ssia1Form();
}
}
}
我又在add new item 对话框 Tenmplates 创建了新的窗体名字叫ssia1
我在第一个代码中添加了一个mainMenu的控件
然后在第一个空间中写入 Next 我想实现他调用其他窗口的话命令该怎么写
我双击了Next在代码中写了
NextForm newForm=new ssia1Form();
可是他提示错误说找不到类型或者命名空间
是怎么一回事代码如下请高手分析:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;namespace ssia
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem menuItem4;
private System.Windows.Forms.MenuItem menuItem5;
private System.Windows.Forms.MenuItem menuItem6;
private System.Windows.Forms.MenuItem menuItem7;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null; public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.menuItem6 = new System.Windows.Forms.MenuItem();
this.menuItem7 = new System.Windows.Forms.MenuItem();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(152, 88);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(224, 21);
this.textBox1.TabIndex = 0;
this.textBox1.Text = "显示你要的数字";
//
// button1
//
this.button1.Location = new System.Drawing.Point(112, 160);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(96, 24);
this.button1.TabIndex = 1;
this.button1.Text = "开始";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(280, 160);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(96, 23);
this.button2.TabIndex = 2;
this.button2.Text = "关闭";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1,
this.menuItem4,
this.menuItem6});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem2,
this.menuItem3,
this.menuItem5,
this.menuItem7});
this.menuItem1.Text = "文件 ";
//
// menuItem2
//
this.menuItem2.Index = 0;
this.menuItem2.Text = "打开记事本";
this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
//
// menuItem3
//
this.menuItem3.Index = 1;
this.menuItem3.Text = "打开计算机";
this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
//
// menuItem4
//
this.menuItem4.Index = 1;
this.menuItem4.Text = "&Next";
this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
//
// menuItem5
//
this.menuItem5.Index = 2;
this.menuItem5.Text = "关闭";
this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click);
//
// menuItem6
//
this.menuItem6.Index = 2;
this.menuItem6.Shortcut = System.Windows.Forms.Shortcut.Alt1;
this.menuItem6.Text = "&Worker";
this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
//
// menuItem7
//
this.menuItem7.Index = 3;
this.menuItem7.Text = "&Next";
this.menuItem7.Click += new System.EventHandler(this.menuItem7_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(480, 294);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox1);
this.Menu = this.mainMenu1;
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false); }
#endregion /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
} private void button1_Click(object sender, System.EventArgs e)
{ string msg="";
Hashtable hashtable =new Hashtable();
Random rm=new Random();
for (int i=1;hashtable.Count<7;i++)
{ int ch=rm.Next(31);
if (!hashtable.ContainsValue(ch)&&ch!=0)
{ hashtable.Add(ch,ch);
msg+=ch.ToString()+"→";
textBox1.Text = msg;}
}
} private void button2_Click(object sender, System.EventArgs e)
{
this.Close();
} private void menuItem2_Click(object sender, System.EventArgs e)
{
System.Diagnostics.Process.Start("notepad.exe");
} private void menuItem3_Click(object sender, System.EventArgs e)
{System.Diagnostics.Process.Start("calc.exe");
} private void menuItem5_Click(object sender, System.EventArgs e)
{
this.Close();
} private void menuItem6_Click(object sender, System.EventArgs e)
{
} private void menuItem4_Click(object sender, System.EventArgs e)
{
} private void menuItem7_Click(object sender, System.EventArgs e)
{
Next newForm = new ssia1Form();
}
}
}
解决方案 »
- 能不能伪装进程名?
- 急求 急求 感激不尽 关于分页显示
- 求教dll加密的问题。
- wpf 中使用PropertyGrid时如何定制属性里的控件类型?
- 我这样的人怎么写简历?请大家帮我出出主意!
- 一个简单的游戏编程问题,如果随便画一个关闭的轨迹线,选中里面的物体?
- 已经引用了“应用程序集”,但在后台代码中却看不见
- datagrid模板列中每行有两个dropdownlist ddla ddlb 怎样在ddla 的改变事件中 动态绑定同一行的ddlb
- 请教c#中实现打印窗体的代码
- 复制多个控件时,当事件触发时能知道是哪个复制的控件引发的吗?100分全送了
- XmlDocument的锁定和释放问题
- 各位高手快帮帮忙,求一个电子邮箱的正则表达式
这样不行吧?又没多态
ssia1Form s1=new ssia1Form();
s1.para=1
这个代码该怎么去实现这个功能