问题描述
[size=10px]staticvoidMain(){Application.Run(newForm1());}publicpartialclassFormall:Form//D:C#xianshiForm1.cs(103):类、结构或接口成员声明中的标记“class”无效{staticintx=200staticinty=200;staticintcount=0;privatevoidbutton1_Click(objectsender,System.EventArgse){Formallform2=newForm1();form2.FormBorderStyle=FormBorderStyle.Fixed3D;form2.Cursor=Cursors.Hand;form2.SetDesktopLocation(x,y);form2.Visible=true;x+=30;y+=30;this.Activate();this.button1.Enabled=false;}privatevoidForm1_Load(objectsender,System.EventArgse){count+=1;}privatevoidForm1_Closed(objectsender,System.EventArgse){count-=1;}privatevoidForm1_Closing(objectsender,System.ComponentModel.CancelEventArgse){if(MessageBox.Show("确定要关闭窗体吗?","确定",MessageBoxButtons.OKCancel)==DialogResult.Cancel)e.Cancel=true;}privatevoidForm1_Activated(objectsender,System.EventArgse){label1.Text="新窗体的坐标("+x+","+y+")";label2.Text="这是第"+count+"个窗体";}privatevoidbutton2_Click(objectsender,System.EventArgse){this.Hide();}}}
解决方案
解决方案二:
form1在哪里?
解决方案三:
把form1.cs的代码贴上来看看
解决方案四:
usingSystem;usingSystem.Drawing;usingSystem.Collections;usingSystem.ComponentModel;usingSystem.Windows.Forms;usingSystem.Data;namespacexianshi{///<summary>///Form1的摘要说明。///</summary>publicclassForm1:System.Windows.Forms.Form{privateSystem.Windows.Forms.Buttonbutton1;privateSystem.Windows.Forms.Buttonbutton2;///<summary>///必需的设计器变量。///</summary>privateSystem.ComponentModel.Containercomponents=null;publicForm1(){////Windows窗体设计器支持所必需的//InitializeComponent();////TODO:在InitializeComponent调用后添加任何构造函数代码//}///<summary>///清理所有正在使用的资源。///</summary>protectedoverridevoidDispose(booldisposing){if(disposing){if(components!=null){components.Dispose();}}base.Dispose(disposing);}#regionWindows窗体设计器生成的代码///<summary>///设计器支持所需的方法-不要使用代码编辑器修改///此方法的内容。///</summary>privatevoidInitializeComponent(){this.button1=newSystem.Windows.Forms.Button();this.button2=newSystem.Windows.Forms.Button();this.SuspendLayout();////button1//this.button1.Location=newSystem.Drawing.Point(72,112);this.button1.Name="button1";this.button1.TabIndex=0;this.button1.Text="显示新窗体";this.button1.Click+=newSystem.EventHandler(this.button1_Click);////button2//this.button2.Location=newSystem.Drawing.Point(192,112);this.button2.Name="button2";this.button2.TabIndex=1;this.button2.Text="隐藏窗体";this.button2.Click+=newSystem.EventHandler(this.button2_Click);////Form1//this.AutoScaleBaseSize=newSystem.Drawing.Size(6,14);this.ClientSize=newSystem.Drawing.Size(304,198);this.Controls.Add(this.button2);this.Controls.Add(this.button1);this.MaximizeBox=false;this.MinimizeBox=false;this.Name="Form1";this.Text="窗体属性、方法、事件演示";this.Closing+=newSystem.ComponentModel.CancelEventHandler(this.Form1_Closing);this.Load+=newSystem.EventHandler(this.Form1_Load);this.Closed+=newSystem.EventHandler(this.Form1_Closed);this.Activated+=newSystem.EventHandler(this.Form1_Activated);this.ResumeLayout(false);}#endregion///<summary>///应用程序的主入口点。///</summary>[STAThread]staticvoidMain(){Application.Run(newForm1());}这是前面的,麻烦大虾看一下!