技术开发 频道

.NET 2.0: Winform下PictureBox控件新增的ImageLocation属性和Pictur

【IT168 技术文档】代码示例:
private System.Windows.Forms.PictureBox pictureBox1; this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill; this.pictureBox1.ImageLocation = "http://www.microsoft.com/h/en-us/i/ts_1024_25_KidsandSpyware.jpg"; this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;



    在WinForm 2.0下,新增加的ImageLocation属性支持文件系统或者Web上的图像位置。这使得显示一个源自万维网上图像的任务变得十分简单。

    PictureBox的SizeMode属性的类型是枚举型PicturBoxSizeMode,在1.x下有Autosize, CenterImage, Normal和StretchImage四个值。WinForm 2.0中新增加了Zoom,这个模式下图像在根据PictureBox大小缩放的时候保持纵横比(aspect ratio)。

0
相关文章