frmfirstmain.cs

来自「用C#编的非常好的程序」· CS 代码 · 共 390 行

CS
390
字号
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace winappFirst
{
	/// <summary>
	/// Form1 的摘要说明。
	/// </summary>
	public class frmFirstMain : System.Windows.Forms.Form
	{
		private System.Windows.Forms.MainMenu mmFirst;
		private System.Windows.Forms.MenuItem miFile;
		private System.Windows.Forms.MenuItem miOpen;
		private System.Windows.Forms.MenuItem miExit;
		private System.Windows.Forms.MenuItem miClose;
		private System.Windows.Forms.MenuItem miSepFile1;
		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 miComm;
		private System.Windows.Forms.MenuItem miGraphic;
		private System.Windows.Forms.MenuItem miDataInForm;
		private System.Windows.Forms.ToolBar tbrMain;
		private System.Windows.Forms.ToolBarButton tbrOpen;
		private System.Windows.Forms.ToolBarButton toolBarButton2;
		private System.Windows.Forms.ToolBarButton toolBarButton3;
		private System.Windows.Forms.ToolBarButton toolBarButton4;
		private System.Windows.Forms.ToolBarButton toolBarButton5;
		private System.Windows.Forms.StatusBarPanel stbp1;
		private System.Windows.Forms.StatusBarPanel stbp2;
		private System.Windows.Forms.StatusBarPanel stbpNow;
		private System.Windows.Forms.StatusBar stbMain;
		private System.Windows.Forms.Timer TimerMain;
		private System.ComponentModel.IContainer components;

		public frmFirstMain()
		{
			//
			// 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.components = new System.ComponentModel.Container();
			this.mmFirst = new System.Windows.Forms.MainMenu();
			this.miFile = new System.Windows.Forms.MenuItem();
			this.miOpen = new System.Windows.Forms.MenuItem();
			this.miComm = new System.Windows.Forms.MenuItem();
			this.miSepFile1 = new System.Windows.Forms.MenuItem();
			this.miExit = new System.Windows.Forms.MenuItem();
			this.miClose = new System.Windows.Forms.MenuItem();
			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.miGraphic = new System.Windows.Forms.MenuItem();
			this.miDataInForm = new System.Windows.Forms.MenuItem();
			this.tbrMain = new System.Windows.Forms.ToolBar();
			this.tbrOpen = new System.Windows.Forms.ToolBarButton();
			this.toolBarButton2 = new System.Windows.Forms.ToolBarButton();
			this.toolBarButton3 = new System.Windows.Forms.ToolBarButton();
			this.toolBarButton4 = new System.Windows.Forms.ToolBarButton();
			this.toolBarButton5 = new System.Windows.Forms.ToolBarButton();
			this.stbMain = new System.Windows.Forms.StatusBar();
			this.stbp1 = new System.Windows.Forms.StatusBarPanel();
			this.stbp2 = new System.Windows.Forms.StatusBarPanel();
			this.stbpNow = new System.Windows.Forms.StatusBarPanel();
			this.TimerMain = new System.Windows.Forms.Timer(this.components);
			((System.ComponentModel.ISupportInitialize)(this.stbp1)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.stbp2)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.stbpNow)).BeginInit();
			this.SuspendLayout();
			// 
			// mmFirst
			// 
			this.mmFirst.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					this.miFile,
																					this.menuItem1,
																					this.menuItem3,
																					this.miGraphic,
																					this.miDataInForm});
			// 
			// miFile
			// 
			this.miFile.Index = 0;
			this.miFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																				   this.miOpen,
																				   this.miComm,
																				   this.miSepFile1,
																				   this.miExit,
																				   this.miClose});
			this.miFile.Text = "File(&F)";
			// 
			// miOpen
			// 
			this.miOpen.Index = 0;
			this.miOpen.Text = "Open";
			this.miOpen.Click += new System.EventHandler(this.miOpen_Click);
			// 
			// miComm
			// 
			this.miComm.Index = 1;
			this.miComm.Text = "常用控件";
			this.miComm.Click += new System.EventHandler(this.miComm_Click);
			// 
			// miSepFile1
			// 
			this.miSepFile1.Index = 2;
			this.miSepFile1.Text = "-";
			// 
			// miExit
			// 
			this.miExit.Index = 3;
			this.miExit.Text = "Exit";
			this.miExit.Click += new System.EventHandler(this.miExit_Click);
			// 
			// miClose
			// 
			this.miClose.Index = 4;
			this.miClose.Text = "Close";
			this.miClose.Click += new System.EventHandler(this.miClose_Click);
			// 
			// menuItem1
			// 
			this.menuItem1.Index = 1;
			this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem2});
			this.menuItem1.Text = "edit";
			// 
			// menuItem2
			// 
			this.menuItem2.Checked = true;
			this.menuItem2.Index = 0;
			this.menuItem2.Text = "sss";
			// 
			// menuItem3
			// 
			this.menuItem3.Index = 2;
			this.menuItem3.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem4});
			this.menuItem3.Text = "常用语句";
			// 
			// menuItem4
			// 
			this.menuItem4.Index = 0;
			this.menuItem4.Text = "";
			// 
			// miGraphic
			// 
			this.miGraphic.Index = 3;
			this.miGraphic.Text = "画图";
			this.miGraphic.Click += new System.EventHandler(this.miGraphic_Click);
			// 
			// miDataInForm
			// 
			this.miDataInForm.Index = 4;
			this.miDataInForm.Text = "窗体间数据传输";
			this.miDataInForm.Click += new System.EventHandler(this.miDataInForm_Click);
			// 
			// tbrMain
			// 
			this.tbrMain.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
																					   this.tbrOpen,
																					   this.toolBarButton2,
																					   this.toolBarButton3,
																					   this.toolBarButton4,
																					   this.toolBarButton5});
			this.tbrMain.DropDownArrows = true;
			this.tbrMain.Location = new System.Drawing.Point(0, 0);
			this.tbrMain.Name = "tbrMain";
			this.tbrMain.ShowToolTips = true;
			this.tbrMain.Size = new System.Drawing.Size(656, 41);
			this.tbrMain.TabIndex = 1;
			// 
			// tbrOpen
			// 
			this.tbrOpen.Text = "Open";
			// 
			// stbMain
			// 
			this.stbMain.Location = new System.Drawing.Point(0, 371);
			this.stbMain.Name = "stbMain";
			this.stbMain.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
																					   this.stbp1,
																					   this.stbp2,
																					   this.stbpNow});
			this.stbMain.ShowPanels = true;
			this.stbMain.Size = new System.Drawing.Size(656, 22);
			this.stbMain.TabIndex = 2;
			this.stbMain.Text = "stbMain";
			// 
			// stbp1
			// 
			this.stbp1.Width = 200;
			// 
			// stbp2
			// 
			this.stbp2.Text = "statusBarPanel2";
			// 
			// stbpNow
			// 
			this.stbpNow.Width = 300;
			// 
			// TimerMain
			// 
			this.TimerMain.Tick += new System.EventHandler(this.TimerMain_Tick);
			// 
			// frmFirstMain
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(656, 393);
			this.Controls.Add(this.stbMain);
			this.Controls.Add(this.tbrMain);
			this.IsMdiContainer = true;
			this.Menu = this.mmFirst;
			this.Name = "frmFirstMain";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "我的第一个C#程序";
			this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
			this.Closing += new System.ComponentModel.CancelEventHandler(this.frmFirstMain_Closing);
			this.Load += new System.EventHandler(this.frmFirstMain_Load);
			((System.ComponentModel.ISupportInitialize)(this.stbp1)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.stbp2)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.stbpNow)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new frmFirstMain());
		}

		private void btnOpenWindow_Click(object sender, System.EventArgs e)
		{
		    
			// vb   frmSecond.Show();
			  

			 //  int i = 0;

			  frmSecond Tfrmsed  = new frmSecond();
			   
			   Tfrmsed.Show();
			  
              


		}

		private void frmFirstMain_Load(object sender, System.EventArgs e)
		{
		
			//MessageBox.Show("欢迎进入第一个程序!","First",MessageBoxButtons.OK,MessageBoxIcon.Information);


			//   程序运行的一些初始化工作

			TimerMain.Start();

			




		

		}

		private void miOpen_Click(object sender, System.EventArgs e)
		{

			frmSecond Tfrmsed  = new frmSecond();

			Tfrmsed.MdiParent=this;
			   
			Tfrmsed.Show();
		
		}

		private void miExit_Click(object sender, System.EventArgs e)
		{
		
			Application.Exit();


		}

		private void miClose_Click(object sender, System.EventArgs e)
		{
			
			TimerMain.Stop();

			this.Close();
		}

		private void frmFirstMain_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			//MessageBox.Show("bye!!","First",MessageBoxButtons.OK,MessageBoxIcon.Information);

		
		}

		private void miComm_Click(object sender, System.EventArgs e)
		{
		
			frmComm  Tfrmcom= new frmComm();
			Tfrmcom.MdiParent=this;
			Tfrmcom.Show();



		}

		private void miGraphic_Click(object sender, System.EventArgs e)
		{
		
			frmGraphic  Tfrmgra=new frmGraphic();
			Tfrmgra.MdiParent=this;
			Tfrmgra.Show();




		}

		private void miDataInForm_Click(object sender, System.EventArgs e)
		{
		
			frmDataInForm  Tfrmdatainformp=new frmDataInForm();
			Tfrmdatainformp.MdiParent=this;
			Tfrmdatainformp.Show();





		}

		private void TimerMain_Tick(object sender, System.EventArgs e)
		{

			stbpNow.Text=DateTime.Now.ToString();
		
		}

		
		
		

	
	}
}

⌨️ 快捷键说明

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