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

📄 frmcomm.cs

📁 用C#编的非常好的程序
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace winappFirst
{
	/// <summary>
	/// frmComm 的摘要说明。
	/// </summary>
	public class frmComm : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.TextBox txtTestBox;
		private System.Windows.Forms.ContextMenu cmmuText;
		private System.Windows.Forms.MenuItem miWriteIn;
		private System.Windows.Forms.MenuItem miClear;
		private System.Windows.Forms.ListBox lbxTest;
		private System.Windows.Forms.Button button2;
		private System.Windows.Forms.ComboBox cbxTest;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmComm()
		{
			//
			// 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.button1 = new System.Windows.Forms.Button();
			this.txtTestBox = new System.Windows.Forms.TextBox();
			this.cmmuText = new System.Windows.Forms.ContextMenu();
			this.miWriteIn = new System.Windows.Forms.MenuItem();
			this.miClear = new System.Windows.Forms.MenuItem();
			this.lbxTest = new System.Windows.Forms.ListBox();
			this.button2 = new System.Windows.Forms.Button();
			this.cbxTest = new System.Windows.Forms.ComboBox();
			this.SuspendLayout();
			// 
			// button1
			// 
			this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.button1.Location = new System.Drawing.Point(336, 16);
			this.button1.Name = "button1";
			this.button1.TabIndex = 0;
			this.button1.Text = "button1";
			// 
			// txtTestBox
			// 
			this.txtTestBox.ContextMenu = this.cmmuText;
			this.txtTestBox.Location = new System.Drawing.Point(48, 8);
			this.txtTestBox.MaxLength = 8;
			this.txtTestBox.Name = "txtTestBox";
			this.txtTestBox.Size = new System.Drawing.Size(160, 21);
			this.txtTestBox.TabIndex = 1;
			this.txtTestBox.Text = "textBox1";
			// 
			// cmmuText
			// 
			this.cmmuText.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					 this.miWriteIn,
																					 this.miClear});
			// 
			// miWriteIn
			// 
			this.miWriteIn.Index = 0;
			this.miWriteIn.Text = "写入“in\"";
			this.miWriteIn.Click += new System.EventHandler(this.miWriteIn_Click);
			// 
			// miClear
			// 
			this.miClear.Index = 1;
			this.miClear.Text = "擦除";
			this.miClear.Click += new System.EventHandler(this.miClear_Click);
			// 
			// lbxTest
			// 
			this.lbxTest.ItemHeight = 12;
			this.lbxTest.Location = new System.Drawing.Point(48, 56);
			this.lbxTest.Name = "lbxTest";
			this.lbxTest.SelectionMode = System.Windows.Forms.SelectionMode.MultiSimple;
			this.lbxTest.Size = new System.Drawing.Size(96, 112);
			this.lbxTest.TabIndex = 2;
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(160, 48);
			this.button2.Name = "button2";
			this.button2.TabIndex = 3;
			this.button2.Text = "button2";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// cbxTest
			// 
			this.cbxTest.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cbxTest.Location = new System.Drawing.Point(168, 96);
			this.cbxTest.MaxDropDownItems = 2;
			this.cbxTest.Name = "cbxTest";
			this.cbxTest.Size = new System.Drawing.Size(121, 20);
			this.cbxTest.TabIndex = 4;
			// 
			// frmComm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(528, 381);
			this.Controls.Add(this.cbxTest);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.lbxTest);
			this.Controls.Add(this.txtTestBox);
			this.Controls.Add(this.button1);
			this.Name = "frmComm";
			this.Text = "常用基本控件";
			this.Load += new System.EventHandler(this.frmComm_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void miWriteIn_Click(object sender, System.EventArgs e)
		{
			txtTestBox.Text="in";
		}

		private void miClear_Click(object sender, System.EventArgs e)
		{
			txtTestBox.Text="";
		}

		private void frmComm_Load(object sender, System.EventArgs e)
		{
		
			
			lbxTest.Items.Add("信息管理");
			lbxTest.Items.Add("工商管理");
			lbxTest.Items.Add("管理科学");
			lbxTest.Items.Add("工业工程");

			//lbxTest.SelectedIndex=2;


			cbxTest.Items.Add("aaa");
			cbxTest.Items.Add("bbb");
			cbxTest.Items.Add("ccc");
			cbxTest.Items.Add("ddd");






		}

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

			if (lbxTest.SelectedItems.Count >0)

			{
				for  (int i=0;i<lbxTest.SelectedItems.Count;i++)
				{

                  MessageBox.Show( lbxTest.SelectedItems[i].ToString());

				}
				 
			 
				
			}
		}
	}
}

⌨️ 快捷键说明

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