回 帖 发 新 帖 刷新版面

主题:动态创建的frae和滚动条,想滑动滚动条时frame向上或向下跟着移动。为何滚动条无反应?请问版主我

 

Private Sub Form_Load()


Set Frame0 = Controls.Add("VB.frame", "Frame0") '创建能整体移动的frame
' Set Frame0.Container = Form1
Frame0.Move 400, 1000, 4000, 5000
Frame0.BackColor = &HFFFFF
Frame0.Visible = True

Set VScroll1 = Controls.Add("VB.VScrollbar", "VScroll1") '创建能控件frame移动的滚动条
' Set VScroll1.Container = Form
VScroll1.Move Frame0.Width + 400, 1000, 400, Frame0.Height
VScroll1.TabStop = False
VScroll1.Visible = True

VScroll1.Min = 0
VScroll1.Max = Frame0.Height
VScroll1.SmallChange = 100
VScroll1.LargeChange = Frame0.Height

End Sub
Private Sub VScroll1_Change()
Frame0.Move 400, -VScroll1.Value
End Sub

Private Sub VScroll1_Scroll() '请问对于动态创建的可不可以这样写Private Sub VScroll1_Scroll()
Frame0.Move 400, -VScroll1.Value
End Sub

0

回复列表 (共2个回复)

沙发

Private WithEvents Frame0 As Frame
Private WithEvents VScroll1 As VScrollBar

Private Sub Form_Load()
Set Frame0 = Controls.Add("VB.Frame", "Frame0") '创建能整体移动的frame
Frame0.Move 400, 1000, 4000, 5000
Frame0.BackColor = &HFFFFF
Frame0.Visible = True

Set VScroll1 = Controls.Add("VB.VScrollbar", "VScroll1") '创建能控件frame移动的滚动条
VScroll1.Move Frame0.Width + 400, 1000, 400, Frame0.Height
VScroll1.TabStop = False
VScroll1.Visible = True

VScroll1.Min = 0
VScroll1.Max = Frame0.Height
VScroll1.SmallChange = 100
VScroll1.LargeChange = Frame0.Height

End Sub

Private Sub VScroll1_Change()
Frame0.Move 400, 1000 - VScroll1.Value
End Sub

Private Sub VScroll1_Scroll()
Frame0.Move 400, 1000 - VScroll1.Value
End Sub

板凳

解放号杰微刊优质译文

我来回复

您尚未登录,请登录后再回复。点此登录或注册