100165545.htm
来自「C#高级编程(第三版),顶死你们。。 。up」· HTM 代码 · 共 72 行
HTM
72 行
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
19.3.11 PictureBox控件
</title></head>
<body>
<div class="area">
<div class="col1">
<div class="lineBlue">
</div>
<!-- title -->
<div class="arcTitle">
<h1>
<a href="../16">
C#高级编程(第3版)【全文连载】
</a>
</h1>
<div style="text-align: center; font-size: 15px">
<a href="100165545.htm">
19.3.11 PictureBox控件
</a>
</div>
<div style="text-align: center; font-size: 15px">
<a class="url" href="../../default.htm">http://book.csdn.net/</a>
2006-10-13 14:41:00
</div>
<div style="margin: 0px auto; width: 700px; border: solid 1px #0b5f98;">
<div style="float: left; width: 16px; background-color: #0b5f98; color: White; padding: 1px;">
图书导读
</div>
<div style="float: right; width: 670px; text-align: left; line-height: 16pt; padding-left: 2px">
<!--导读-->
<h1 id="divCurrentNode" style="color: #b83507; width: 100%; text-align: left; font-size: 12px; padding-left: 2px">当前章节:<a href='100165545.htm'><font color='red'>19.3.11 PictureBox控件</font></a></h1>
<div id="divRelateNode" style="padding-left: 2px">
<div style='float:left;width:49%'>·<a href='100165542.htm'>19.3.8 Label控件</a></div><div style='float:right;width:49%'>·<a href='100165543.htm'>19.3.9 ListView控件</a></div><div style='float:left;width:49%'>·<a href='100165544.htm'>19.3.10 Panel控件</a></div><div style='float:right;width:49%'>·<a href='100165546.htm'>19.3.12 ProgressBar控件</a></div><div style='float:left;width:49%'>·<a href='100165547.htm'>19.3.13 RadioButton控件</a></div><div style='float:right;width:49%'>·<a href='100165548.htm'>19.3.14 TextBox控件与RichTextBox控件</a></div></div>
</div>
</div>
</div>
<!-- main -->
<div id="main">
<div id="text"> <link href="css.css" rel="stylesheet" type="text/css" /><h3 style="MARGIN-TOP: 8.15pt; MARGIN-LEFT: 0cm; MARGIN-RIGHT: 0cm; FTEL: 8.15pt"><span lang="EN-US">19.3.11 PictureBox</span><span style="FONT-FAMILY: 黑体">控件</span></h3>
<p class="MsoNormal"><span lang="EN-US">PictureBox</span><span style="FONT-FAMILY: 宋体">控件用于显示图像。图像可以是</span><span lang="EN-US">BMP</span><span style="FONT-FAMILY: 宋体">、</span><span lang="EN-US">JPEG</span><span style="FONT-FAMILY: 宋体">、</span><span lang="EN-US">GIF</span><span style="FONT-FAMILY: 宋体">、</span><span lang="EN-US">PNG</span><span style="FONT-FAMILY: 宋体">、元文件或图标。</span><span lang="EN-US">SizeMode</span><span style="FONT-FAMILY: 宋体">属性使用</span><span lang="EN-US">PictureBoxSizeMode</span><span style="FONT-FAMILY: 宋体">枚举确定图像在控件中的大小和位置。</span><span lang="EN-US">SizeMode</span><span style="FONT-FAMILY: 宋体">属性可以是</span><span lang="EN-US">AutoSize</span><span style="FONT-FAMILY: 宋体">、</span><span lang="EN-US">CenterImage</span><span style="FONT-FAMILY: 宋体">、</span><span lang="EN-US">Normal</span><span style="FONT-FAMILY: 宋体">和</span><span lang="EN-US">StretchImage</span><span style="FONT-FAMILY: 宋体">。</span></p>
<p class="MsoNormal"><span style="FONT-FAMILY: 宋体">设置</span><span lang="EN-US">ClientSize</span><span style="FONT-FAMILY: 宋体">属性,可以改变</span><span lang="EN-US">PictureBox</span><span style="FONT-FAMILY: 宋体">的显示区域大小。要加载</span><span lang="EN-US">PictureBox</span><span style="FONT-FAMILY: 宋体">,首先创建一个基于</span><span lang="EN-US">Iamge</span><span style="FONT-FAMILY: 宋体">的对象。例如,要把</span><span lang="EN-US">JPEG</span><span style="FONT-FAMILY: 宋体">文件加载到</span><span lang="EN-US">PictureBox</span><span style="FONT-FAMILY: 宋体">中,需要编写如下代码:</span></p>
<p class="2" style="MARGIN-TOP: 8.15pt; MARGIN-LEFT: 21.45pt; MARGIN-RIGHT: 0cm; FTEL: 18.45pt"><span lang="EN-US">Bitmap myJpeg = new Bitmap(" mypic.jpg");</span></p>
<p class="2" style="MARGIN-TOP: 0cm; MARGIN-LEFT: 21.45pt; MARGIN-RIGHT: 0cm; FTEL: 18.45pt"><span lang="EN-US">pictureBox1.Image = (Image) myJpeg;</span></p>
<p class="MsoNormal"><span style="FONT-FAMILY: 宋体">注意需要转换回</span><span lang="EN-US">Image</span><span style="FONT-FAMILY: 宋体">类型,因为这是</span><span lang="EN-US">Image</span><span style="FONT-FAMILY: 宋体">属性所要求的。</span></p></div>
<!-- page -->
<div class="page" style="text-align: center">
<a href="100165544.htm">上一页</a> <a href="index.html">首页</a> <a href="100165546.htm">下一页</a>
</div>
<div style="margin: 0px auto; width: 700px; border: solid 1px #0b5f98;">
<div style="float: left; width: 16px; background-color: #0b5f98; color: White; padding: 1px;">
图书导读
</div>
<div style="float: right; width: 670px; text-align: left; line-height: 16pt; padding-left: 2px">
<!--导读-->
<h1 id="divCurrentNode2" style="color: #b83507; width: 100%; text-align: left; font-size: 12px; padding-left: 2px">当前章节:<a href='100165545.htm'><font color='red'>19.3.11 PictureBox控件</font></a></h1>
<div id="divRealteNod2" style="padding-left: 2px">
<div style='float:left;width:49%'>·<a href='100165542.htm'>19.3.8 Label控件</a></div><div style='float:right;width:49%'>·<a href='100165543.htm'>19.3.9 ListView控件</a></div><div style='float:left;width:49%'>·<a href='100165544.htm'>19.3.10 Panel控件</a></div><div style='float:right;width:49%'>·<a href='100165546.htm'>19.3.12 ProgressBar控件</a></div><div style='float:left;width:49%'>·<a href='100165547.htm'>19.3.13 RadioButton控件</a></div><div style='float:right;width:49%'>·<a href='100165548.htm'>19.3.14 TextBox控件与RichTextBox控件</a></div></div>
</div>
</div>
</div>
</div>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?