⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainform.cs

📁 北大青鸟内部资料
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace ApplicationForm
{
	/// <summary>
	/// Summary description for Main.
	/// </summary>
	public class MainForm : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button btnAdd;
		private System.Windows.Forms.ComboBox cboSelectItem;
		private System.Windows.Forms.Button btnExit;
		private System.Windows.Forms.Label lblInfo;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public MainForm()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			
			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}
		[STAThread]
		static void Main() 
		{
			Application.Run(new MainForm());
		}
		#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()
		{
			this.btnAdd = new System.Windows.Forms.Button();
			this.cboSelectItem = new System.Windows.Forms.ComboBox();
			this.btnExit = new System.Windows.Forms.Button();
			this.lblInfo = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// btnAdd
			// 
			this.btnAdd.Location = new System.Drawing.Point(125, 95);
			this.btnAdd.Name = "btnAdd";
			this.btnAdd.Size = new System.Drawing.Size(90, 25);
			this.btnAdd.TabIndex = 0;
			this.btnAdd.Text = "添加(&A)";
			this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
			// 
			// cboSelectItem
			// 
			this.cboSelectItem.Items.AddRange(new object[] {
															   "Student",
															   "Employee"});
			this.cboSelectItem.Location = new System.Drawing.Point(154, 34);
			this.cboSelectItem.Name = "cboSelectItem";
			this.cboSelectItem.Size = new System.Drawing.Size(172, 20);
			this.cboSelectItem.TabIndex = 2;
			// 
			// btnExit
			// 
			this.btnExit.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.btnExit.ImeMode = System.Windows.Forms.ImeMode.NoControl;
			this.btnExit.Location = new System.Drawing.Point(240, 95);
			this.btnExit.Name = "btnExit";
			this.btnExit.Size = new System.Drawing.Size(90, 25);
			this.btnExit.TabIndex = 16;
			this.btnExit.Text = "退出(&X)";
			this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
			// 
			// lblInfo
			// 
			this.lblInfo.Location = new System.Drawing.Point(19, 34);
			this.lblInfo.Name = "lblInfo";
			this.lblInfo.Size = new System.Drawing.Size(120, 25);
			this.lblInfo.TabIndex = 17;
			this.lblInfo.Text = "选择类别:";
			// 
			// MainForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(355, 134);
			this.Controls.Add(this.lblInfo);
			this.Controls.Add(this.btnExit);
			this.Controls.Add(this.cboSelectItem);
			this.Controls.Add(this.btnAdd);
			this.Name = "MainForm";
			this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show;
			this.Text = "主窗体";
			this.ResumeLayout(false);

		}
		#endregion

		//Show modal form to add student details or employee details depends on option selected
		private void btnAdd_Click(object sender, System.EventArgs e)
		{
			if(string.Compare(this.cboSelectItem.Text.Trim(),"Student",false)==0)
			{
				AddStudentForm objStdForm = new AddStudentForm();
				objStdForm.ShowDialog();
			}
			
			else if (string.Compare(this.cboSelectItem.Text.Trim(),"Employee",false)==0)
			{
				AddEmployeeForm objEmpForm = new AddEmployeeForm();
				objEmpForm.ShowDialog();
			}

		}
		
		//Close the form
		private void btnExit_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -