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

📄 form1.cs

📁 Csharp实例编程百例.rar
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace testCheckRadioApp
{
	/// <summary>
	/// Form1 的摘要说明。
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.CheckBox chkDisableMax;
		private System.Windows.Forms.CheckBox chkDisableMin;
		private System.Windows.Forms.CheckBox chkDisableShow;
		private System.Windows.Forms.RadioButton rdColorBlue;
		private System.Windows.Forms.RadioButton rdColorRed;
		private System.Windows.Forms.RadioButton rdColorYellow;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Form1()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.chkDisableMax = new System.Windows.Forms.CheckBox();
			this.chkDisableMin = new System.Windows.Forms.CheckBox();
			this.chkDisableShow = new System.Windows.Forms.CheckBox();
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.rdColorBlue = new System.Windows.Forms.RadioButton();
			this.rdColorRed = new System.Windows.Forms.RadioButton();
			this.rdColorYellow = new System.Windows.Forms.RadioButton();
			this.groupBox1.SuspendLayout();
			this.SuspendLayout();
			// 
			// chkDisableMax
			// 
			this.chkDisableMax.Location = new System.Drawing.Point(8, 16);
			this.chkDisableMax.Name = "chkDisableMax";
			this.chkDisableMax.TabIndex = 0;
			this.chkDisableMax.Text = "允许最大化";
			this.chkDisableMax.CheckedChanged += new System.EventHandler(this.chkDisableMax_CheckedChanged);
			// 
			// chkDisableMin
			// 
			this.chkDisableMin.Location = new System.Drawing.Point(8, 56);
			this.chkDisableMin.Name = "chkDisableMin";
			this.chkDisableMin.TabIndex = 1;
			this.chkDisableMin.Text = "允许最小化";
			this.chkDisableMin.CheckedChanged += new System.EventHandler(this.chkDisableMin_CheckedChanged);
			// 
			// chkDisableShow
			// 
			this.chkDisableShow.Location = new System.Drawing.Point(8, 96);
			this.chkDisableShow.Name = "chkDisableShow";
			this.chkDisableShow.Size = new System.Drawing.Size(128, 20);
			this.chkDisableShow.TabIndex = 2;
			this.chkDisableShow.Text = "在任务栏中显示";
			this.chkDisableShow.CheckedChanged += new System.EventHandler(this.chkDisableShow_CheckedChanged);
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.rdColorBlue,
																					this.rdColorRed,
																					this.rdColorYellow});
			this.groupBox1.Location = new System.Drawing.Point(149, 13);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(203, 128);
			this.groupBox1.TabIndex = 3;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "背景色设置";
			// 
			// rdColorBlue
			// 
			this.rdColorBlue.Location = new System.Drawing.Point(16, 88);
			this.rdColorBlue.Name = "rdColorBlue";
			this.rdColorBlue.TabIndex = 2;
			this.rdColorBlue.Text = "蓝色";
			this.rdColorBlue.CheckedChanged += new System.EventHandler(this.rdColorBlue_CheckedChanged);
			// 
			// rdColorRed
			// 
			this.rdColorRed.Location = new System.Drawing.Point(16, 56);
			this.rdColorRed.Name = "rdColorRed";
			this.rdColorRed.TabIndex = 1;
			this.rdColorRed.Text = "红色";
			this.rdColorRed.CheckedChanged += new System.EventHandler(this.rdColorRed_CheckedChanged);
			// 
			// rdColorYellow
			// 
			this.rdColorYellow.Location = new System.Drawing.Point(16, 24);
			this.rdColorYellow.Name = "rdColorYellow";
			this.rdColorYellow.TabIndex = 0;
			this.rdColorYellow.Text = "黄色";
			this.rdColorYellow.CheckedChanged += new System.EventHandler(this.rdColorYellow_CheckedChanged);
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(368, 150);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.groupBox1,
																		  this.chkDisableShow,
																		  this.chkDisableMin,
																		  this.chkDisableMax});
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "Form1";
			this.ShowInTaskbar = false;
			this.Text = "testCheckRadioApp";
			this.groupBox1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

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

		private void chkDisableShow_CheckedChanged(object sender, System.EventArgs e)
		{
			this.ShowInTaskbar = chkDisableShow.Checked ;
		}

		private void chkDisableMax_CheckedChanged(object sender, System.EventArgs e)
		{
			this.MaximizeBox = chkDisableMax.Checked ;
		}

		private void chkDisableMin_CheckedChanged(object sender, System.EventArgs e)
		{
			this.MinimizeBox = chkDisableMin.Checked;
		}

		private void rdColorYellow_CheckedChanged(object sender, System.EventArgs e)
		{
			if (rdColorYellow.Checked)
			{
				this.BackColor = Color.Yellow ;
			}
		}

		private void rdColorRed_CheckedChanged(object sender, System.EventArgs e)
		{
			if (rdColorRed.Checked)
			{
				this.BackColor = Color.Red ;
			}

		}

		private void rdColorBlue_CheckedChanged(object sender, System.EventArgs e)
		{
			if (rdColorBlue.Checked)
			{
				this.BackColor = Color.Blue ;
			}

		}

	}
}

⌨️ 快捷键说明

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