我在C#中有多个表单,当我调试时,不会显示更多表单
我对C#相当陌生,但是当我尝试调试我的程序时,什么都没有显示。我有多个表单,第一个表单只是一个菜单,所以我可以转到其他表单 这是我的我在C#中有多个表单,当我调试时,不会显示更多表单,c#,winforms,C#,Winforms,我对C#相当陌生,但是当我尝试调试我的程序时,什么都没有显示。我有多个表单,第一个表单只是一个菜单,所以我可以转到其他表单 这是我的表格1.cs: namespace EscapeLabryinth { public partial class frmMainMenu : Form { frmGameMenu secondForm = new frmGameMenu(); frmHowToPlay thirdForm = new frmHowToP
表格1.cs
:
namespace EscapeLabryinth
{
public partial class frmMainMenu : Form
{
frmGameMenu secondForm = new frmGameMenu();
frmHowToPlay thirdForm = new frmHowToPlay();
Music bgMusic;
public frmMainMenu()
{
InitializeComponent();
}
private void btnPlay_Click(object sender, EventArgs e)
{
secondForm.Show();
this.Hide();
}
private void btnInstru_Click(object sender, EventArgs e)
{
thirdForm.Show();
this.Hide();
}
private void btnQuit_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void btnAudio_Click(object sender, EventArgs e)
{
}
private void frmMainMenu_Load(object sender, EventArgs e)
{
//Create a new Music object to play the background music
bgMusic = new Music(Application.StartupPath + @"\resources\music\eurekaost.wav", true);
bgMusic.LoopPlay();
bgMusic.SetVolume(-100);
}
}
}
这是同一表单的设计器:
namespace EscapeLabryinth
{
partial class frmMainMenu
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmMainMenu));
this.btnQuit = new System.Windows.Forms.Button();
this.lblTitleMenu = new System.Windows.Forms.Label();
this.btnAudio = new System.Windows.Forms.Button();
this.btnInstru = new System.Windows.Forms.Button();
this.btnPlay = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// btnQuit
//
this.btnQuit.BackColor = System.Drawing.Color.Firebrick;
this.btnQuit.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnQuit.Font = new System.Drawing.Font("Hand Me Down S BRK", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnQuit.Location = new System.Drawing.Point(250, 290);
this.btnQuit.Name = "btnQuit";
this.btnQuit.Size = new System.Drawing.Size(150, 39);
this.btnQuit.TabIndex = 2;
this.btnQuit.Text = "Quit";
this.btnQuit.UseVisualStyleBackColor = false;
this.btnQuit.Click += new System.EventHandler(this.btnQuit_Click);
//
// lblTitleMenu
//
this.lblTitleMenu.AutoSize = true;
this.lblTitleMenu.BackColor = System.Drawing.Color.Black;
this.lblTitleMenu.Font = new System.Drawing.Font("Vindictive BRK", 21.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblTitleMenu.ForeColor = System.Drawing.Color.White;
this.lblTitleMenu.Location = new System.Drawing.Point(83, 18);
this.lblTitleMenu.Name = "lblTitleMenu";
this.lblTitleMenu.Size = new System.Drawing.Size(532, 28);
this.lblTitleMenu.TabIndex = 3;
this.lblTitleMenu.Text = "Venture The Great Labryinth";
//
// btnAudio
//
this.btnAudio.BackgroundImage = global::EscapeLabryinth.Properties.Resources.speakers;
this.btnAudio.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.btnAudio.Location = new System.Drawing.Point(632, 355);
this.btnAudio.Name = "btnAudio";
this.btnAudio.Size = new System.Drawing.Size(54, 73);
this.btnAudio.TabIndex = 4;
this.btnAudio.UseVisualStyleBackColor = true;
this.btnAudio.Click += new System.EventHandler(this.btnAudio_Click);
//
// btnInstru
//
this.btnInstru.BackColor = System.Drawing.Color.DarkSlateGray;
this.btnInstru.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnInstru.Font = new System.Drawing.Font("Hand Me Down S BRK", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnInstru.Location = new System.Drawing.Point(253, 190);
this.btnInstru.Name = "btnInstru";
this.btnInstru.Size = new System.Drawing.Size(150, 39);
this.btnInstru.TabIndex = 5;
this.btnInstru.Text = "How To Play";
this.btnInstru.UseVisualStyleBackColor = false;
this.btnInstru.Click += new System.EventHandler(this.btnInstru_Click);
//
// btnPlay
//
this.btnPlay.BackColor = System.Drawing.Color.Gold;
this.btnPlay.FlatAppearance.BorderSize = 0;
this.btnPlay.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnPlay.Font = new System.Drawing.Font("Hand Me Down S BRK", 21.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnPlay.ForeColor = System.Drawing.Color.Black;
this.btnPlay.Location = new System.Drawing.Point(250, 92);
this.btnPlay.Name = "btnPlay";
this.btnPlay.Size = new System.Drawing.Size(150, 39);
this.btnPlay.TabIndex = 6;
this.btnPlay.Text = "Venture!";
this.btnPlay.UseVisualStyleBackColor = false;
this.btnPlay.Click += new System.EventHandler(this.btnPlay_Click);
//
// frmMainMenu
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackgroundImage = global::EscapeLabryinth.Properties.Resources.labyrinth;
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.ClientSize = new System.Drawing.Size(687, 437);
this.Controls.Add(this.btnPlay);
this.Controls.Add(this.btnInstru);
this.Controls.Add(this.btnAudio);
this.Controls.Add(this.lblTitleMenu);
this.Controls.Add(this.btnQuit);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "frmMainMenu";
this.Text = "Main Menu";
this.Load += new System.EventHandler(this.frmMainMenu_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button btnQuit;
private System.Windows.Forms.Label lblTitleMenu;
private System.Windows.Forms.Button btnAudio;
private System.Windows.Forms.Button btnInstru;
private System.Windows.Forms.Button btnPlay;
}
}
namespace EscapeLabryinth
{
部分类frmMainMenu
{
///
///必需的设计器变量。
///
private System.ComponentModel.IContainer components=null;
///
///清理所有正在使用的资源。
///
///如果应释放托管资源,则为true;否则为false。
受保护的覆盖无效处置(布尔处置)
{
if(处理和(组件!=null))
{
组件。Dispose();
}
基地。处置(处置);
}
#区域Windows窗体设计器生成的代码
///
///设计器支持所需的方法-不修改
///此方法的内容与代码编辑器一起使用。
///
私有void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager资源=新的System.ComponentModel.ComponentResourceManager(类型(frmMainMenu));
this.btnQuit=new System.Windows.Forms.Button();
this.lblTitleMenu=new System.Windows.Forms.Label();
this.btnAudio=new System.Windows.Forms.Button();
this.btnInstru=new System.Windows.Forms.Button();
this.btnPlay=new System.Windows.Forms.Button();
这个.SuspendLayout();
//
//B放弃
//
this.btnQuit.BackColor=System.Drawing.Color.Firebrick;
this.btnQuit.FlatStyle=System.Windows.Forms.FlatStyle.Popup;
this.btnQuit.Font=new System.Drawing.Font(“Hand-Me-Down S BRK”,20.25F,System.Drawing.FontStyle.Regular,System.Drawing.GraphicsUnit.Point,((字节)(0));
this.btnQuit.Location=新系统.图纸.点(250290);
this.btnQuit.Name=“btnQuit”;
this.btnQuit.Size=新系统.图纸.尺寸(150,39);
this.btnQuit.TabIndex=2;
this.btnQuit.Text=“退出”;
this.btnQuit.UseVisualStyleBackColor=false;
this.btnQuit.Click+=新建System.EventHandler(this.btnQuit\u Click);
//
//lblTitleMenu
//
this.lblTitleMenu.AutoSize=true;
this.lblTitleMenu.BackColor=System.Drawing.Color.Black;
this.lblTitleMenu.Font=new System.Drawing.Font(“报复性BRK”,21.75F,System.Drawing.FontStyle.Regular,System.Drawing.GraphicsUnit.Point,((字节)(0));
this.lblTitleMenu.ForeColor=System.Drawing.Color.White;
this.lblTitleMenu.Location=新系统.图纸.点(83,18);
this.lblTitleMenu.Name=“lblTitleMenu”;
this.lblTitleMenu.Size=新系统.Drawing.Size(532,28);
this.lblTitleMenu.TabIndex=3;
this.lblTitleMenu.Text=“大胆尝试伟大的劳动”;
//
//b诺迪奥
//
this.btnAudio.BackgroundImage=global::EscapeLabryinth.Properties.Resources.speakers;
this.btnAudio.BackgroundImageLayout=System.Windows.Forms.ImageLayout.Stretch;
this.btnAudio.Location=新系统图纸点(632355);
this.btnAudio.Name=“btnAudio”;
this.btnAudio.Size=新系统图纸尺寸(54,73);
this.btnAudio.TabIndex=4;
this.btnAudio.UseVisualStyleBackColor=true;
this.btnAudio.Click+=newsystem.EventHandler(this.btnAudio\u Click);
//
//Btnistru
//
this.btnInstru.BackColor=System.Drawing.Color.DarkSlateGray;
this.btnInstru.FlatStyle=System.Windows.Forms.FlatStyle.Flat;
this.btnInstru.Font=new System.Drawing.Font(“Hand-Me-Down S BRK”,18F,System.Drawing.FontStyle.Regular,System.Drawing.GraphicsUnit.Point,((字节)(0));
this.btnInstru.Location=新系统图纸点(253190);
this.btnInstru.Name=“btnInstru”;
this.btnInstru.Size=新系统图纸尺寸(150,39);
this.btnInstru.TabIndex=5;
this.btnInstru.Text=“如何播放”;
this.btnInstru.UseVisualStyleBackColor=false;
this.btnInstru.Click+=新建System.EventHandler(this.btnInstru\u Click);
//
//btnPlay
//
this.btnPlay.BackColor=System.Drawing.Color.Gold;
this.btnPlay.flateAppearance.BorderSize=0;
this.btnPlay.FlatStyle=System.Windows.Forms.FlatStyle.Popup;
this.btnPlay.Font=new System.Drawing.Font(“Hand-Me-Down S BRK”,21.75F,System.Drawing.FontStyle.Regular,System.Drawing.GraphicsUnit.Point,((字节)(0));
this.btnPlay.ForeColor=System.Drawing.Color.Black;
this.btnPlay.Location=新系统.图纸.点(250,92);
this.btnPlay.Name=“btnPlay”;
this.btnPlay.Size=新系统.图纸.尺寸(150,39);
this.btnPlay.TabIndex=6;
this.btnPlay.Text=“Venture!”;
this.btnPlay.UseVisualStyleBackColor=false;
this.btnPlay.Click+=新建System.EventHandler(this.btnPlay\u Click);
//
//FRM菜单
//
此.AutoScaleDimensions=新系统.Drawing.SizeF(6F,13F);
this.AutoScaleMode=System.Windows.Forms.AutoScaleMode.Font;
this.BackgroundImage=global::EscapeLabryinth.Properties.Resources.迷宫;
this.BackgroundImageLayout=System.Windows.Forms.ImageLayout.Stretch;
this.ClientSize=新系统.Drawing.Size(687437);
this.Controls.Add(this.btnPlay);
this.Controls.Add(this.btnInstru);
这
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmMainMenu());
}
}