使用PictureBox.SizeMode的详细讲解
首先让我们看看类里面是什么?
下图所示:
我们发现这个属性用了枚举 : PictureBoxSizeMode
这个枚举也让我们进去看看(按F12可以跟踪)
我们看到一个这样的东西:
展开所有的注释:
得到下面列表的内容:
| 枚举值 | 名字 | 介绍 |
|---|---|---|
| 0 | Normal | 图像被置于 System.Windows.Forms.PictureBox 的左上角。如果图像比包含它的 System.Windows.Forms.PictureBox 大,则该图像将被剪裁掉。 |
| 1 | StretchImage | System.Windows.Forms.PictureBox 中的图像被拉伸或收缩,以适合 System.Windows.Forms.PictureBox的大小。 |
| 2 | AutoSize | 调整 System.Windows.Forms.PictureBox 大小,使其等于所包含的图像大小。 |
| 3 | CenterImage | 如果 System.Windows.Forms.PictureBox 比图像大,则图像将居中显示。如果图像比 System.Windows.Forms.PictureBox大,则图片将居于 System.Windows.Forms.PictureBox 中心,而外边缘将被剪裁掉。 |
| 4 | Zoom | 图像大小按其原有的大小比例被增加或减小。 |
每一种方法我都写个展示图出来:
右图是原图展示(做 对比 \ 参考 使用)
Normal:(控件默认)
(该美女图片来自百度)
StretchImage:
(该美女图片来自百度)
AutoSize :
(该美女图片来自百度)
CenterImage:
(该美女图片来自百度)
Zoom:
(该美女图片来自百度)