Solved

Scroll Bars Component for Visual Basic

Posted on 2002-07-07
4
208 Views
Last Modified: 2013-11-25
Where Cand I download an VB Component to control my Form scroll bars??
I don't want to programme all the lines to adapt my form to the scroll bars that come in visual basic. I want a componet that does this automatically...
does it exists???

THANKS
0
Comment
Question by:mltolun
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 22

Accepted Solution

by:
rspahitz earned 100 total points
ID: 7138363
If I understand you correctly, you want a form that has a scrollable display area.  I have not seen such a form, but creating a control for it is relatively simple.

To do this, simply add a picturebox (named picScrollPanel, borderless) into the form, add horizontal and vertical scroll bars (named scrHorizontal and scrVertical, tabstop property=false) on the bottom and right, then add a textbox (named txtHideCorner, frameless, background=buttonface, text blank) to the lower right corner to hide that spot.

In your form's resize procedure:

Private Sub Form_Resize()
  scrHorizontal.Move 0, Me.ScaleHeight - scrHorizontal.Height, Me.ScaleWidth - scrVertical.Width
  scrVertical.Move Me.ScaleWidth - scrVertical.Width, 0, scrVertical.Width, Me.ScaleHeight - scrHorizontal.Height
  txtHideSpot.Move scrVertical.Left, scrHorizontal.Top, scrVertical.Width, scrHorizontal.Height
  picScrollWindow.Move 0, 0, 'scrVertical.Left, scrHorizontal.Top' no need to resize the picturebox or the scrolling effect won't work!
 
  ' Set scroll bar max
  lScrollMax = Me.ScaleWidth - picScrollWindow.Width
  If lScrollMax <= 0 Then
    scrHorizontal.Max = -lScrollMax
  Else
    scrHorizontal.Max = scrHorizontal.Min
  End If
 
  lScrollMax = Me.ScaleHeight - picScrollWindow.Height
  If lScrollMax <= 0 Then
    scrVertical.Max = -lScrollMax
  Else
    scrVertical.Max = scrVertical.Min
  End If
End Sub

At design time, place all controls into the picturebox, as large as you'd like.

Then add the following code to make the scrolling work:

Private Sub scrHorizontal_Change()
  picScrollWindow.Left = -scrHorizontal.Value
End Sub

Private Sub scrHorizontal_Scroll()
  scrHorizontal_Change
End Sub

Private Sub scrVertical_Change()
  picScrollWindow.Top = -scrVertical.Value
End Sub

Private Sub scrVertical_Scroll()
  scrVertical_Change
End Sub
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 7138376
If I understand you correctly, you want a form that has a scrollable display area.  I have not seen such a form, but creating a control for it is relatively simple.

To do this, simply add a picturebox (named picScrollPanel, borderless) into the form, add horizontal and vertical scroll bars (named scrHorizontal and scrVertical, tabstop property=false) on the bottom and right, then add a textbox (named txtHideCorner, frameless, background=buttonface, text blank) to the lower right corner to hide that spot.

In your form's resize procedure:

Private Sub Form_Resize()
  scrHorizontal.Move 0, Me.ScaleHeight - scrHorizontal.Height, Me.ScaleWidth - scrVertical.Width
  scrVertical.Move Me.ScaleWidth - scrVertical.Width, 0, scrVertical.Width, Me.ScaleHeight - scrHorizontal.Height
  txtHideSpot.Move scrVertical.Left, scrHorizontal.Top, scrVertical.Width, scrHorizontal.Height
  picScrollWindow.Move 0, 0, 'scrVertical.Left, scrHorizontal.Top' no need to resize the picturebox or the scrolling effect won't work!
 
  ' Set scroll bar max
  lScrollMax = Me.ScaleWidth - picScrollWindow.Width
  If lScrollMax <= 0 Then
    scrHorizontal.Max = -lScrollMax
  Else
    scrHorizontal.Max = scrHorizontal.Min
  End If
 
  lScrollMax = Me.ScaleHeight - picScrollWindow.Height
  If lScrollMax <= 0 Then
    scrVertical.Max = -lScrollMax
  Else
    scrVertical.Max = scrVertical.Min
  End If
End Sub

At design time, place all controls into the picturebox, as large as you'd like.

Then add the following code to make the scrolling work:

Private Sub scrHorizontal_Change()
  picScrollWindow.Left = -scrHorizontal.Value
End Sub

Private Sub scrHorizontal_Scroll()
  scrHorizontal_Change
End Sub

Private Sub scrVertical_Change()
  picScrollWindow.Top = -scrVertical.Value
End Sub

Private Sub scrVertical_Scroll()
  scrVertical_Change
End Sub
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7990833
Hi mltolun,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept rspahitz's comment(s) as an answer.

mltolun, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.
==========
DanRollins -- EE database cleanup volunteer
0
 

Expert Comment

by:SpideyMod
ID: 8053140
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question