使用PictureBox.SizeMode的详细讲解

429 阅读1分钟

使用PictureBox.SizeMode的详细讲解

首先让我们看看类里面是什么?

下图所示:

类中的属性

我们发现这个属性用了枚举 : PictureBoxSizeMode

这个枚举也让我们进去看看(按F12可以跟踪)

我们看到一个这样的东西:
PictureBoxSizeMode枚举介绍

展开所有的注释:
所有注释展开的效果

得到下面列表的内容:

枚举值名字介绍
0Normal图像被置于 System.Windows.Forms.PictureBox 的左上角。如果图像比包含它的 System.Windows.Forms.PictureBox 大,则该图像将被剪裁掉。
1StretchImageSystem.Windows.Forms.PictureBox 中的图像被拉伸或收缩,以适合 System.Windows.Forms.PictureBox的大小。
2AutoSize调整 System.Windows.Forms.PictureBox 大小,使其等于所包含的图像大小。
3CenterImage如果 System.Windows.Forms.PictureBox 比图像大,则图像将居中显示。如果图像比 System.Windows.Forms.PictureBox大,则图片将居于 System.Windows.Forms.PictureBox 中心,而外边缘将被剪裁掉。
4Zoom图像大小按其原有的大小比例被增加或减小。

每一种方法我都写个展示图出来:
右图是原图展示(做 对比 \ 参考 使用)

Normal:(控件默认)
(该美女图片来自百度)
Normal图片展示

StretchImage:
(该美女图片来自百度)
StretchImage图片展示

AutoSize :
(该美女图片来自百度)
AutoSize图片展示

CenterImage:
(该美女图片来自百度)
在这里插入图片描述

Zoom:
(该美女图片来自百度)
在这里插入图片描述