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

📄 compoundcontrol.cs

📁 《c#技术内幕代码》
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

namespace CH13_5
{
	/// <summary>
	/// Summary description for CompoundControl.
	/// </summary>
	public class CompoundControl : System.Windows.Forms.UserControl
	{
		// Allow a handler for the event
		public delegate Boolean ValueChangedEventHandler(int nValue);

		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.ComboBox comboBox1;
		/// <summary> 
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
		public event ValueChangedEventHandler Changed;

		public CompoundControl()
		{
			// This call is required by the Windows.Forms Form Designer.
			InitializeComponent();

			// TODO: Add any initialization after the InitForm 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 );
		}

		#region Component 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.comboBox1 = new System.Windows.Forms.ComboBox();
			this.label1 = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// comboBox1
			// 
			this.comboBox1.DropDownWidth = 121;
			this.comboBox1.Items.AddRange(new object[] {
														   "New York",
														   "Colorado",
														   "California",
														   "Florida",
														   "Georgia",
														   "New Mexico"});
			this.comboBox1.Location = new System.Drawing.Point(24, 48);
			this.comboBox1.Name = "comboBox1";
			this.comboBox1.Size = new System.Drawing.Size(200, 21);
			this.comboBox1.TabIndex = 1;
			this.comboBox1.Text = "comboBox1";
			this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.OnSelectionIndexChange);
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(16, 24);
			this.label1.Name = "label1";
			this.label1.TabIndex = 0;
			this.label1.Text = "Select An Entry";
			// 
			// CompoundControl
			// 
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.comboBox1,
																		  this.label1});
			this.Name = "CompoundControl";
			this.Size = new System.Drawing.Size(240, 96);
			this.ResumeLayout(false);

		}
		#endregion

		private void OnSelectionIndexChange(object sender, System.EventArgs e)
		{
			if (Changed != null)
				Changed( this.comboBox1.SelectedIndex);

		}
	}
}

⌨️ 快捷键说明

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