[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Scroll Bars Component for Visual Basic

Posted on 2002-07-07
4
Medium Priority
?
214 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
  • 2
4 Comments
 
LVL 22

Accepted Solution

by:
rspahitz earned 400 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

830 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