ImageWidth 屬性

此頁(yè)沒有內(nèi)容條目
內(nèi)容

expandtri全部顯示

Visual Basic 中,使用 ImageWidth 屬性可以決定圖像控件中以為單位的圖像寬度。Long 型,可讀寫。

expression.ImageWidth

expression     必需。返回“應(yīng)用于”列表中的一個(gè)對(duì)象的表達(dá)式。

說(shuō)明

ImageWidth 屬性是一個(gè) Integer 值,該值等于圖片以緹為單位的寬度值。

該屬性在所有視圖中都是只讀的。

ImageWidth 屬性與 ImageHeight 屬性一起使用,可以決定圖像控件中圖片的大小,并可以使用該信息更改圖像控件的 HeightWidth 屬性,以調(diào)整控件使之能夠與所顯示的圖片大小相匹配。

示例

下面的示例提示用戶輸入位圖文件名,然后將該位圖文件指定給 Image1 圖像控件的 Picture 屬性。ImageHeightImageWidth 屬性則用于將圖像控件調(diào)整到符合位圖的大小。

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