在picturebox放置VScroll滚动条控件,动态加载label控件 ,不能实现滚动显示?
vb6中 在窗体上建一个容器picture3,并添加滚动条控件,picture4放在picture3内, 在picture4内动态添加label控件用其canption属性来显示数值,想用滚动条来控制显示超出picture3范围的内容,运行后,拖动滚动条后,超出部分显示的是空白,没人label内容,请高手帮忙看看,怎么回事。但在picture4上加载图片,用滚动条则能实现滚动浏览。
Dim top2,h as Integer
Private Sub Form_Load()
Me.VScroll1.Visible = False '滚动条不可见
Me.Picture4.AutoSize = True
Me.VScroll1.Min = 0
Me.VScroll1.Max = Me.Picture4.Height t - Me.Picture3.Height
Me.VScroll1.LargeChange = 365
Set labl(h) = Me.Controls.Add("VB.Label", "labl" & h, Picture4)
' top2 = 3720 + 365 * (h - 1)
top2 = 365 * (h - 1)
With labl(h)
' labl(h).left = 120
labl(h).left = -10
labl(h).Top = top2
labl(h).Width = 2295
labl(h).Height = 375
labl(h).Visible = True
labl(h).BackStyle = 0
labl(h).BorderStyle = 1
labl(h).Appearance = 0
labl(h).Alignment = 2
labl(h).FontSize = 8
labl(h).Caption = tmparry(h)
End With
End sub
Private Sub VScroll1_Change()
Me.Picture4.Top = VScroll1.Value
End Sub
Private Sub VScroll1_Scroll()
Me.Picture4.Top = VScroll1.Value
End Sub
[此贴子已经被作者于2019-7-29 15:42编辑过]