dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Jan 3, 2001

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Making a Form Scrollable


This is one of the simplest, but most powerful, ways to make a form scrollable. This method automatically disables or enables scrollbars according to the size of the area in relation to the form.
  • Add a Picturebox
  • Add a VScrollBar
  • Add a HScrollBar
  • Add the following code to the form:
  •  
    Private Sub Form_Resize() 
        VScroll1.Move ScaleWidth - VScroll1.Width, ScaleTop, VScroll1.Width, ScaleHeight - HScroll1.Height 
        HScroll1.Move ScaleLeft, ScaleHeight - HScroll1.Height, ScaleWidth - VScroll1.Width, HScroll1.Height 
        
        Scrolling 
    End Sub 
    Private Sub Scrolling() 
        If Picture1.Width > (ScaleWidth - VScroll1.Width) Then 
            HScroll1.Max = Picture1.Width - (ScaleWidth - VScroll1.Width) 
            HScroll1.Enabled = True 
        Else 
            HScroll1.Max = HScroll1.Min 
            HScroll1.Enabled = False 
        End If 
        
        If Picture1.Height > (ScaleHeight - HScroll1.Height) Then 
            VScroll1.Max = Picture1.Height - (ScaleHeight - VScroll1.Height) 
            VScroll1.Enabled = True 
        Else 
            VScroll1.Max = VScroll1.Min 
            VScroll1.Enabled = False 
        End If 
        
        Picture1.Move -HScroll1.Value, -VScroll1.Value 
    End Sub 
    Private Sub HScroll1_Change() 
        Scrolling 
    End Sub 
    Private Sub VScroll1_Change() 
        Scrolling 
    End Sub 
    
Andreas Hillqvist
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date