ImageWidth 属性

expandtri全部显示

Visual Basic 中,使用 ImageWidth 属性可以决定图像控件中以为单位的图像宽度。Long 型,可读写。

expression.ImageWidth

expression     必需。返回“应用于”列表中的一个对象的表达式。

说明

ImageWidth 属性是一个 Integer 值,该值等于图片以缇为单位的宽度值。

该属性在所有视图中都是只读的。

ImageWidth 属性与 ImageHeight 属性一起使用,可以决定图像控件中图片的大小,并可以使用该信息更改图像控件的 HeightWidth 属性,以调整控件使之能够与所显示的图片大小相匹配。

示例

下面的示例提示用户输入位图文件名,然后将该位图文件指定给 Image1 图像控件的 Picture 属性。ImageHeightImageWidth 属性则用于将图像控件调整到符合位图的大小。

Sub GetNewPicture(frm As Form)

    Dim ctlImage As Control

    Set ctlImage = frm!Image1

    ctlImage.Picture = InputBox("Enter path and " _

        & "file name for new bitmap")

    ctlImage.Height = ctlImage.ImageHeight

    ctlImage.Width = ctlImage.ImageWidth

End Sub