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

📄 myusercontrol.cs

📁 ASP C#代码实例 适合初学人士学习使用
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

namespace WindowsControl
{
	/// <summary>
	/// Summary description for MyUserControl.
	/// </summary>
	public class MyUserControl : System.Windows.Forms.UserControl
	{
		private System.Windows.Forms.Label myLabel;
		private System.Windows.Forms.Button myButton;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

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

			// TODO: Add any initialization after the InitComponent 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.myLabel = new System.Windows.Forms.Label();
			this.myButton = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// myLabel
			// 
			this.myLabel.Dock = System.Windows.Forms.DockStyle.Top;
			this.myLabel.Location = new System.Drawing.Point(0, 0);
			this.myLabel.Name = "myLabel";
			this.myLabel.Size = new System.Drawing.Size(150, 23);
			this.myLabel.TabIndex = 0;
			this.myLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// myButton
			// 
			this.myButton.Location = new System.Drawing.Point(32, 96);
			this.myButton.Name = "myButton";
			this.myButton.TabIndex = 1;
			this.myButton.Text = "确  定";
			this.myButton.Click += new System.EventHandler(this.myButton_Click);
			// 
			// MyUserControl
			// 
			this.Controls.Add(this.myButton);
			this.Controls.Add(this.myLabel);
			this.Name = "MyUserControl";
			this.ResumeLayout(false);

		}
		#endregion

		private void myButton_Click(object sender, System.EventArgs e)
		{
			myLabel.Text = "Hello world.";
		}
	}
}

⌨️ 快捷键说明

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