All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
PHP实例:PHP上传自动生成缩略图及水印类_[PHP教程]
Linux环境下如何使用PHP处理图像_[PHP教程]
php 截取中文_[PHP教程]
实战经验:PHP+MySQL数据库论坛简易通_php资料_编程技术
AJAX实例:Ajax实现静态页面分页_[AJAX教程]
怎么样学习PHP_[PHP教程]
TechED,VS2008课件_[Asp.Net教程]
微软新版开发工具VS,2008,beta2功能定案_.net资料_编程技术
由浅入深学习动态网页制作PHP的编程与应用_php资料_编程技术
SQL中CASE使用_mssql学习_编程技术
Reading number is top 10 pictures
初五接财神啦!五路财神齐来到
美女和狗狗2
这是男生笨么?
牛奶和人奶哪个好?
这玉米,买还是不卖?
LiXiang early youth photo
程序员的悲哀
美洲杯宝贝的雨中风情1
NeedWallpaper13
一万二一支的万珂,用得真心肉疼。
Download software ranking
美女游泳记
The king of fighters 97(Mobile phone games-apk)
Take off clothes to survival
在线棋牌游戏3.05版
金山office2007
Boxer vs Yellow2
Tram sex maniac 2 (H) rar bag5
Tram sex maniac 2 (H) rar bag12
VeryCD电驴(EasyMule) V1.1.9 Build09081
Boxer's Top ten classic battle7
qq published in(发表于) 2014/7/11 9:17:08 Edit(编辑)
C#中ImageList组件应用实例

C#中ImageList组件应用实例

C#中ImageList组件应用实例

ImageList组件

1.功能

ImageList组件用于存储图像,这些图像可由控件显示。图像列表能够为一致的单个图像目录编写代码。图1所示为ImageList组件。



图1 ImageList组件

2.属性

ImageList组件常用属性及说明如表1所示。



表1 ImageList组件常用属性及说明

下面详细介绍Images属性,此属性表示图像列表中包含图像的集合。

语法:

public ImageCollection Images { get; }
属性值:图像集合。

示例

Images属性的使用

本示例主要是通过Images属性为pictureBox1控件的Image属性赋值。

程序主要代码如下:

this.pictureBox1.Image = imageList1.Images[0];

this.pictureBox2.Image = imageList1.Images[1];

完整程序代码如下:

★★★★★主程序文件完整程序代码★★★★★

using System;

using System.Collections.Generic;

using System.Windows.Forms;

namespace _8_11

{

static class Program

{

///



/// 应用程序的主入口点。

///


[STAThread]

static void Main()

{

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

Application.Run(new frmPictureBox());

}

}

}

★★★★★frmPictureBox窗体设计文件完整程序代码★★★★★

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace _8_11

{

public partial class frmPictureBox : Form

{

public frmPictureBox()

{

InitializeComponent();

}

private void frmPictureBox_Load(object sender, EventArgs e)

{

this.pictureBox1.Image = imageList1.Images[0];

this.pictureBox2.Image = imageList1.Images[1];

this.pictureBox1.SizeMode= PictureBoxSizeMode.StretchImage;

}

private void pictureBox2_Click(object sender, EventArgs e)

{

}

}

}

★★★★★frmPictureBox窗体代码文件完整程序代码★★★★★

namespace _8_11

{

partial class frmPictureBox

{

///

/// 必需的设计器变量。

///


private System.ComponentModel.IContainer components = null;

///

/// 清理所有正在使用的资源。

///


/// 如果应释放托管资源,为 true;否则为 false。

protected override void Dispose(bool disposing)

{

if (disposing && (components != null))

{

components.Dispose();

}

base.Dispose(disposing);

}

#region Windows 窗体设计器生成的代码

///

/// 设计器支持所需的方法 - 不要

/// 使用代码编辑器修改此方法的内容。

///


private void InitializeComponent()

{

this.components = new System.ComponentModel.Container();

System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmPictureBox));

this.label1 = new System.Windows.Forms.Label();

this.label2 = new System.Windows.Forms.Label();

this.pictureBox2 = new System.Windows.Forms.PictureBox();

this.pictureBox1 = new System.Windows.Forms.PictureBox();

this.imageList1 = new System.Windows.Forms.ImageList(this.components);

((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();

((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();

this.SuspendLayout();

//

// label1

//

this.label1.AutoSize = true;

this.label1.Location = new System.Drawing.Point(70, 52);

this.label1.Name = "label1";

this.label1.Size = new System.Drawing.Size(0, 12);

this.label1.TabIndex = 1;

//

// label2

//

this.label2.AutoSize = true;

this.label2.Font = new System.Drawing.Font("黑体", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));

this.label2.ForeColor = System.Drawing.Color.Red;

this.label2.Location = new System.Drawing.Point(24, 179);

this.label2.Name = "label2";

this.label2.Size = new System.Drawing.Size(0, 19);

this.label2.TabIndex = 5;

//

// pictureBox2

//

this.pictureBox2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;

this.pictureBox2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;

this.pictureBox2.Location = new System.Drawing.Point(139, 33);

this.pictureBox2.Name = "pictureBox2";

this.pictureBox2.Size = new System.Drawing.Size(141, 97);

this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;

this.pictureBox2.TabIndex = 4;

this.pictureBox2.TabStop = false;

this.pictureBox2.Click += new System.EventHandler(this.pictureBox2_Click);

//

// pictureBox1

//

this.pictureBox1.Location = new System.Drawing.Point(28, 33);

this.pictureBox1.Name = "pictureBox1";

this.pictureBox1.Size = new System.Drawing.Size(85, 87);

this.pictureBox1.TabIndex = 0;

this.pictureBox1.TabStop = false;

//

// imageList1

//

this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));

this.imageList1.TransparentColor = System.Drawing.Color.Transparent;

this.imageList1.Images.SetKeyName(0, "Auto.jpg");

this.imageList1.Images.SetKeyName(1, "2005122314034518.jpg");

this.imageList1.Images.SetKeyName(2, "11.bmp");

//

// frmPictureBox

//

this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);

this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

this.ClientSize = new System.Drawing.Size(296, 238);

this.Controls.Add(this.label2);

this.Controls.Add(this.pictureBox2);

this.Controls.Add(this.label1);

this.Controls.Add(this.pictureBox1);

this.Name = "frmPictureBox";

this.Text = "ImageList组件";

this.Load += new System.EventHandler(this.frmPictureBox_Load);

((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();

((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();

this.ResumeLayout(false);

this.PerformLayout();

}

#endregion

private System.Windows.Forms.PictureBox pictureBox1;

private System.Windows.Forms.Label label1;

private System.Windows.Forms.PictureBox pictureBox2;

private System.Windows.Forms.Label label2;

private System.Windows.Forms.ImageList imageList1;

}

}

3.方法


添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.