using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;namespace WindowsFormsApplication1
{
public partial class Form1: Form
{
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
name_txt.Text = "";
bj_txt.Text = "08职考班";
} private void button1_Click(object sender, EventArgs e)
{
if (name_txt.Text == "")
{
MessageBox.Show("姓名不得为空!");
}
else
{
Form2 myForm = new Form2();
myForm.ShowDialog();
}
}
}
}
感谢帮忙修改。
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;namespace WindowsFormsApplication1
{
public partial class Form1: Form
{
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
name_txt.Text = "";
bj_txt.Text = "08职考班";
} private void button1_Click(object sender, EventArgs e)
{
if (name_txt.Text == "")
{
MessageBox.Show("姓名不得为空!");
}
else
{
Form2 myForm = new Form2();
myForm.ShowDialog();
}
}
}
}
感谢帮忙修改。
{
MessageBox.Show("姓名不得为空!");
}
else
{
Form2 myForm = new Form2();
myForm.ShowDialog();
}这里有错误 我是不是也要在 form2这个窗体理写什么代码呢?
if (name_txt.Text == "")
{
MessageBox.Show("姓名不得为空!");
}
else
{
Form2 myForm = new Form2();
myForm.ShowDialog();
}这里有错误 我是不是也要在 form2这个窗体理写什么代码呢?
C:\WINDOWS\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.DataSetExtensions.dll" /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Deployment.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll" /debug+ /debug:full /filealign:512 /optimize- /out:obj\Debug\WindowsFormsApplication1.exe /resource:obj\Debug\WindowsFormsApplication1.Form1.resources /resource:obj\Debug\WindowsFormsApplication1.cj_txt.resources /resource:obj\Debug\WindowsFormsApplication1.Properties.Resources.resources /target:winexe db1DataSet.Designer.cs Form1.cs Form1.Designer.cs Form2.cs Form2.Designer.cs Program.cs Properties\AssemblyInfo.cs Properties\Resources.Designer.cs Properties\Settings.Designer.cs
E:\soft\WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs(32,17): 错误 CS0246: 找不到类型或命名空间名称“Form2”(是否缺少 using 指令或程序集引用?)
E:\soft\WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs(32,36): 错误 CS0246: 找不到类型或命名空间名称“Form2”(是否缺少 using 指令或程序集引用?)编译完成 -- 2 个错误,0 个警告
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========
运行后的错误