Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to attach a scroll bar to a picturebox

How to attach a scroll bar to a picturebox

Scheduled Pinned Locked Moved Visual Basic
tutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MJay
    wrote on last edited by
    #1

    as topic, anyone can provide some codes that enable a scroll bar to a picturebox when the picture expand?

    A 2 Replies Last reply
    0
    • M MJay

      as topic, anyone can provide some codes that enable a scroll bar to a picturebox when the picture expand?

      A Offline
      A Offline
      Anonymous
      wrote on last edited by
      #2

      Drop 2 PictureBoxes on your form, so that Picture1 is Picture2's Container. Drop horizontal and vertical ScrollBar controls on proper positions around Picture1. Set Picture1.AutoSize = False and Picture2.AutoSize = True. As you load picture(s) into Picture2, execute the following code: If Picture2.Width > Picture1.Width Then ScrollBarH.Enabled = True Else ScrollBarH.Enabled = False End If If Picture2.Height > Picture1.Height Then ScrollBarV.Enabled = True Else ScrollBarV.Enabled = False End If Hope, it helps.

      1 Reply Last reply
      0
      • M MJay

        as topic, anyone can provide some codes that enable a scroll bar to a picturebox when the picture expand?

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        In my previous posting I forgot to mention that you control the position of Picture2 relative to Picture1 (which is a Container, remember?) with your scrollbars. The code to do that seems trivial enough: the horizontal scrollbar has to increment/decrement the Picture.Left, while the vertical one controls Picture2.Top properties.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups