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

📄 form1.cs

📁 Visual C#2005程序设计教程
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace WinAppImageList
{
	/// <summary>
	/// Form1 的摘要说明。
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label labShowPic1;
		private System.Windows.Forms.Label labShowPic2;
		private System.Windows.Forms.Label labShowPic3;
		private System.Windows.Forms.ImageList picList;
		private System.ComponentModel.IContainer components;

		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 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
            this.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
            this.labShowPic1 = new System.Windows.Forms.Label();
            this.labShowPic2 = new System.Windows.Forms.Label();
            this.labShowPic3 = new System.Windows.Forms.Label();
            this.picList = new System.Windows.Forms.ImageList(this.components);
            this.SuspendLayout();
            // 
            // labShowPic1
            // 
            this.labShowPic1.BackColor = System.Drawing.Color.Transparent;
            this.labShowPic1.Cursor = System.Windows.Forms.Cursors.Hand;
            this.labShowPic1.Location = new System.Drawing.Point(8, 68);
            this.labShowPic1.Name = "labShowPic1";
            this.labShowPic1.Size = new System.Drawing.Size(373, 206);
            this.labShowPic1.TabIndex = 0;
            this.labShowPic1.Click += new System.EventHandler(this.labShowPic1_Click);
            // 
            // labShowPic2
            // 
            this.labShowPic2.BackColor = System.Drawing.Color.Transparent;
            this.labShowPic2.Cursor = System.Windows.Forms.Cursors.Hand;
            this.labShowPic2.Location = new System.Drawing.Point(8, 68);
            this.labShowPic2.Name = "labShowPic2";
            this.labShowPic2.Size = new System.Drawing.Size(373, 206);
            this.labShowPic2.TabIndex = 1;
            this.labShowPic2.Visible = false;
            this.labShowPic2.Click += new System.EventHandler(this.labShowPic2_Click);
            // 
            // labShowPic3
            // 
            this.labShowPic3.BackColor = System.Drawing.Color.Transparent;
            this.labShowPic3.Cursor = System.Windows.Forms.Cursors.Hand;
            this.labShowPic3.Location = new System.Drawing.Point(8, 68);
            this.labShowPic3.Name = "labShowPic3";
            this.labShowPic3.Size = new System.Drawing.Size(373, 206);
            this.labShowPic3.TabIndex = 2;
            this.labShowPic3.Visible = false;
            this.labShowPic3.Click += new System.EventHandler(this.labShowPic3_Click);
            // 
            // picList
            // 
            this.picList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("picList.ImageStream")));
            this.picList.TransparentColor = System.Drawing.Color.Transparent;
            this.picList.Images.SetKeyName(0, "");
            this.picList.Images.SetKeyName(1, "");
            this.picList.Images.SetKeyName(2, "");
            // 
            // Form1
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(8, 18);
            this.ClientSize = new System.Drawing.Size(392, 346);
            this.Controls.Add(this.labShowPic3);
            this.Controls.Add(this.labShowPic2);
            this.Controls.Add(this.labShowPic1);
            this.MaximizeBox = false;
            this.MaximumSize = new System.Drawing.Size(400, 386);
            this.MinimizeBox = false;
            this.MinimumSize = new System.Drawing.Size(400, 386);
            this.Name = "Form1";
            this.Text = "图片列表示例";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.ResumeLayout(false);

		}
		#endregion

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

		private void Form1_Load(object sender, System.EventArgs e)
		{
			//label1.Image=Image.FromFile("F:\\GIF\\004.GIF");//picList.Images[1];
			labShowPic1.ImageList=picList;
			labShowPic1.ImageIndex=0;
			this.BackgroundImage=picList.Images[0];
		}

		private void labShowPic1_Click(object sender, System.EventArgs e)
		{
			labShowPic1.Hide( );
			labShowPic2.Show( );
			labShowPic2.ImageList=picList;
			labShowPic2.ImageIndex=1;
			this.BackgroundImage=picList.Images[1];
		}

		private void labShowPic2_Click(object sender, System.EventArgs e)
		{
			labShowPic2.Hide( );
			labShowPic3.Show( );
			labShowPic3.ImageList=picList;
			labShowPic3.ImageIndex=2;
			//labShowPic3.Image=picList.Images[2];
			this.BackgroundImage=picList.Images[2];
		}

		private void labShowPic3_Click(object sender, System.EventArgs e)
		{
			labShowPic3.Hide( );
			labShowPic1.Show( );
			labShowPic1.ImageList=picList;
			labShowPic1.ImageIndex=0;
			//labShowPic1.Image=picList.Images[0];
			this.BackgroundImage=picList.Images[0];
		}
	}
}

⌨️ 快捷键说明

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