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

Reading number is top 10 articles
DropDownList控件根据value值选中它_[Asp.Net教程]
在asp.net页面中使用异步读取_.net资料_编程技术
ASP.NET的实时天气及24小时天气预报(C#)_[Asp.Net教程]
有理有力:个人网站的出路在于细分市场_JavaScript技术_编程技术
LINQ体验(6)——LINQ,to,SQL语句之Join和Order,By_[Asp.Net教程]
用好VS2005之扩展membership服务_[Asp.Net教程]
c#中类的方法定义,参数,使用,重载
ASP.NET开发经验(3):使用,GUID,值来作为数据库行标识_[Asp.Net教程]
ASP.NET,2.0,中好东西(theme)介绍_[Asp.Net教程]
PHP实例:PHP和JS实现交互的一个例子_[PHP教程]
Reading number is top 10 pictures
青春清纯美女大集合2
西游日记2
On the verge of extinction of the beach1
A man's favorite things1
这是男生笨么?
治疗多发性骨髓瘤的特效药,一万二一支
Earthquake hedge common sense
XuRe xuan cool and refreshing photoes1
Forced sex girl living abroad2
美女和狗狗2
Download software ranking
Boxer vs Yellow5
Professional killers2 data package
Boxer's Top ten classic battle8
Eclipse 4.2.2 For Win32
美女写真3
Unix video tutorial18
Dance with duck(male prostitution)
徐若瑄成名作“魔鬼天使”
WebService在.NET中的实战应用教学视频 → 第4集
Visual C++界面编程技术
qq published in(发表于) 2014/7/11 9:17:46 Edit(编辑)
C#中PictureBox控件应用实例

C#中PictureBox控件应用实例

C#中PictureBox控件应用实例

PictureBox控件

功能

PictureBox控件用于显示位图、GIF、JPEG、图元文件和图标格式的图形。图1所示为PictureBox控件。




图1 PictureBox控件

2.属性

PictureBox控件常用的属性及说明如表1所示。


表1 PictureBox控件常用属性及说明

下面对比较重要的属性进行详细介绍。

(1)SizeMode属性。此属性用于设置PictureBox控件将如何处理图像位置和大小。

语法:

public PictureBoxSizeModeSizeMode { get; set; }

属性值:PictureBoxSizeMode 值之一,默认为 Normal。

PictureBoxSizeMode:一个返回值,用来处理图像位置和大小。PictureBoxSizeMode的属性值及说明如表2所示。



表2 PictureBoxSizeMode的属性值及说明

(2)Image属性。此属性用于指定图片框中的图片。

语法:

public Image Image { get; set; }

属性值:要显示的Image。

示例

Image属性设置

本示例中,当程序运行时,通过PictureBox控件的Image属性设置要在控件中显示的图片。

程序主要代码如下:

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

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

this.pictureBox1.SizeMode= PictureBoxSizeMode.StretchImage;

3.方法

CancelAsync方法

该方法主要用于取消异步图像加载。

4.事件

PictureBox控件常用事件及说明如表3所示。



表3 PictureBox控件常用事件及说明

下面详细介绍Click事件,该事件在单击图片时发生。

语法:

public event EventHandler Click

完整程序代码如下:

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

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 pictureBox1_Click(object sender, EventArgs e)

{

}

private void button2_Click(object sender, EventArgs e)

{

}

private void timer1_Tick(object sender, EventArgs e)

{

}

private void button1_Click(object sender, EventArgs e)

{

}

private void pictureBox2_Click(object sender, EventArgs e)

{

}

private void timer2_Tick_1(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)


添加到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.