vb里在image中加滚动条遇到一个问题,请速回答~

来源:百度知道 编辑:UC知道 时间:2024/06/24 11:15:15
一个picturebox控件中有三个imagebox,分别是image1,image2,image3
三个是竖成一排排列的,即:

image1.top=0
image2.top=image1.top+image1.height
image3.top=image2.top+image2.height

前边定义了滚动条的max属性
Dim totalh As Integer
totalh = Image1.Height + Image2.Height + Image3.Height
If totalh <= Picture2.Height Then
VScroll1.Visible = False
Else
VScroll1.Max = totalh
VScroll1.Visible = True
End If
=====================
滚动条改变时的事件
Private Sub VScroll1_Change()
Image1.Top = 0 - VScroll1.Value
Image2.Top = Image1.Top + Image1.Height
Image3.Top = Image2.Top + Image2.Height
End Sub

可是实际加载图片后滚动条的max好像会比实际高出许多,把滚动条拉到大概1/4时实际上image3都已经全部显示出来了,想不通了,这么写滚动条拉到最下边时才应该是刚好显示完啊,请问是怎么回事?怎样才能达到滚动条拉到最下边时刚好显示到第3个图片最底端的效果?
自己已解决了
刚才犯迷糊了呵呵
那问题就不关了,就当考大家了呵呵,其实很简单的,谁先答对分给谁吧~关了分也是没了

image1.top=0
image2.top=image1.top+image1.height
image3.top=image2.top+image2.height

前边定义了滚动条的max属性
Dim totalh As Integer
totalh = Image1.Height + Image2.Height + Image3.Height-Picture2.Height'<------此处更改
If totalh <=0 Then'<------此处更改
VScroll1.Visible = False
Else
VScroll1.Max = totalh
VScroll1.Visible = True
End If
=====================
滚动条改变时的事件
Private Sub VScroll1_Change()
Image1.Top = 0 - VScroll1.Value
Image2.Top = Image1.Top + Image1.Height
Image3.Top = Image2.Top + Image2.Height
End Sub