|
-
Jun 19th, 2002, 05:32 PM
#1
Thread Starter
Lively Member
Scrollbar
I have multiple rows of textboxes which I want to scroll using a
vertical scroll bar. I'm also going to have a command button to add
and delete rows of textboxes based on the user's needs. The problem is
that I have this accomplished in VB6 but am not sure how to handle it
using VB.net because there are no control arrays.
Here is the code I have a for a sample of what i am trying to
accomplish done in VB6.. Anyone know how to get this functionality
with VB.net
I'm using a textbox, two command buttons, and 2 picture boxes.
Thanks,
Option Explicit
Private Sub cmdAddAppt_Click()
'Add a new textbox for another appointment and adjust the
scrollbar.
'Note that the scrollbar's max property cannot be less than zero
Dim Index As Integer
Dim ListIndex As Integer
Index = txtAppt().UBound + 1
Load txtAppt(Index)
txtAppt(Index).Top = txtAppt(Index - 1).Top + txtAppt(Index -
1).Height
txtAppt(Index).Text = Empty
txtAppt(Index).Visible = True
picInner.Height = txtAppt(0).Height * txtAppt().Count +
txtAppt(0).Top * 2
vsbAppt.Max = Max(picInner.Height - picOuter.Height, 0)
vsbAppt.SmallChange = picInner.Height * 0.02
vsbAppt.LargeChange = picInner.Height * 0.2
End Sub
Private Sub cmdDelAppt_Click()
'Remove the last appointment textbox and adjust the scrollbar.
'Note that the scrollbar's max property cannot be less than zero
'Warn when trying to remove the last textbox.
Dim Index As Integer
Index = txtAppt().UBound
If Index > 0 Then
Unload txtAppt(Index)
picInner.Height = txtAppt(0).Height * txtAppt().Count +
txtAppt(0).Top
vsbAppt.Max = Max(picInner.Height - picOuter.Height, 0)
Else
MsgBox "Can't unload the last one!"
End If
End Sub
Private Sub Form_Load()
'Set intial values
picInner.Height = txtAppt(0).Height * txtAppt().Count +
txtAppt(0).Top
vsbAppt.Max = Max(picInner.Height - picOuter.Height, 0)
vsbAppt.SmallChange = picInner.Height * 0.02
vsbAppt.LargeChange = picInner.Height * 0.2
End Sub
Private Sub vsbAppt_Change()
'Scroll
picInner.Top = -vsbAppt.Value
End Sub
Private Function Max(a As Integer, b As Integer) As Integer
'Return the larger of two values
Dim result As Integer
If a > b Then
result = a
Else
result = b
End If
Max = result
End Function
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|