?? frmcomm.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 + -