我在ScrollBar
中的de VB6
有问题。观看下一个 gif :
我该如何解决?
这是我的所有代码:
Option Explicit
Private old Post As Integer
Dim index As Integer
Dim indicee As Integer
Public Disclaimer
Private Sub btnAdd_Click ()
index = index + 1 'we increase the index
indicee = indicee + 0 'we start it at 0
pic1 (indicee) .Visible = True
'Label and TextBox type
lblType (indicee) .Visible = True
cmbAddType (indicee) .Visible = True
'Label and TextBox prefix
lblAddPrefix (indicee) .Visible = True
txtAddPrefix (indicee) .Visible = True
'Number Label and TextBox
lblAddNum (indicee) .Visible = True
txtAddNumber (indicee) .Visible = True
chkAddPrincipal (indicee) .Visible = True
'Label and TextBox link
lblAddVin (indicee) .Visible = True
cmbAdd Link (indicee) .Visible = True
'uc1
Load pic1 (index) 'we create the control
pic1 (index) .Visible = True 'we make it visible
pic1 (index) .Top = pic1 (index - 1) .Top + pic1 (index - 1) .Height + 20
'lblType
Load lblType (index)
Set lblType (index) .Container = pic1 (index)
lblType (index) .Visible = True
lblType (index) .Top = lblType (index - 1) .Top
'cmbAddType
Load cmbAddType (index)
Set cmbAddType (index) .Container = pic1 (index)
cmbAddType (index) .Visible = True
cmbAddType (index) .Top = cmbAddTipo (index - 1) .Top
'lblAddPrefix
Load lblAddPrefix (index)
Set lblAddPrefix (index) .Container = pic1 (index)
lblAddPrefix (index) .Visible = True
lblAddPrefix (index) .Top = lblAddPrefix (index - 1) .Top
'txtAddPrefix
Load txtAddPrefix (index)
Set txtAddPrefix (index) .Container = pic1 (index)
txtAddPrefix (index) .Visible = True
txtAddPrefix (index) .Top = txtAddPrefix (index - 1) .Top
'lblAddNum
Load lblAddNum (index)
Set lblAddNum (index) .Container = pic1 (index)
lblAddNum (index) .Visible = True
lblAddNum (index) .Top = lblAddNum (index - 1) .Top
'txtAddNumber
Load txtAddNumber (index)
Set txtAddNumber (index) .Container = pic1 (index)
txtAddNumber (index) .Visible = True
txtAddNumber (index) .Top = txtAddNumber (index - 1) .Top
'checkAddPrincipal
Load chkAddPrincipal (index)
Set chkAddPrincipal (index) .Container = pic1 (index)
chkAddPrincipal (index) .Visible = True
chkAddPrincipal (index) .Top = chkAddPrincipal (index - 1) .Top
'lblAddVin
Load lblAddVin (index)
Set lblAddVin (index) .Container = pic1 (index)
lblAddVin (index) .Visible = True
lblAddVin (index) .Top = lblAddVin (index - 1) .Top
'cmbAdd Link
Load cmbAdd Link (index)
Set cmbAdd Link (index) .Container = pic1 (index)
cmbAdd Link (index) .Visible = True
cmbAddLink (index) .Top = cmbAddLink (index - 1) .Top
End Sub
Private Sub Form_Load ()
scrollAdd.Min = 0
scrollAdd.Max = 1000
scrollAdd.SmallChange = Screen.TwipsPerPixelX * 10
scrollAdd.LargeChange = scrollAdd.SmallChange
End Sub
Private Sub scrollAdd_Change ()
ScrollPictureBox
End Sub
Private Sub scrollAdd_Scroll ()
ScrollPictureBox
End Sub
Private Sub ScrollPictureBox ()
Dim c As Control
For Each c In Me.Controls
If c.Container.Name = "pic1" And Not TypeOf c Is VScrollBar Then
c.Top = c.Top + (oldPos - scrollAdd.Value)
End if
Next
oldPos = scrollAdd.Value
End Sub
有人可以帮助我吗? 我需要使用ScrollBar解决该问题。 我需要它正确移动,我该怎么做?
〜我给您添加了gif可以理解我的“错误/错误” 我的英语不好,但我希望你能听懂 我希望滚动条正确移动而不移动gif中所示的表单。这个想法是,当按下按钮时,将添加字段,并使用ScrollBar可以看到它们,但是正如您将看到的那样,整个表单都在移动,包括ScrollBar〜
我需要的是有一个ScrollBar,它允许滚动查看每次按下按钮时添加的所有元素。