Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8100369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:43:18+00:00 2026-06-05T22:43:18+00:00

I have a panel that is anchored to the top, left, right, bottom of

  • 0

I have a panel that is anchored to the top, left, right, bottom of a Windows form. Inside that panel is a picturebox. That picturebox is resized up and down via a TrackBar control (which is on another panel on the same form with ‘Dock’ property set to Top), and re-centered every time it is resized. The picturebox occasionally grows either too wide or too tall for the panel to contain it. How can I add horizontal and vertical scrollbars to the panel to allow it to ‘pan’ the image within the picturebox? I’ve tried using the autoscroll property, but I can’t seem to get it to do anything and the MSDN documentation is somewhat vague and lists some bugs. I’ve looked over the previous questions here on stack, but can’t find anything that works for my situation. Any ideas?

I’m using Visual Studio 2010 and a VB.NET project, but VB.NET or C# recommendations would be great.

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T22:43:19+00:00Added an answer on June 5, 2026 at 10:43 pm

    There isn’t a single setting for that type of action, because when a PictureBox dimension is smaller than the Panel’s client space, you want the PictureBox to be centered, but when the PictureBox dimensions exceeds the size of the Panel’s client space, you want the location to be at point zero and have the scrollbar handle the view.

    Try handling the panel’s resize event and also call the event when you resize the PictureBox:

    Private Sub TrackBar1_Scroll(sender As Object, e As EventArgs) Handles TrackBar1.Scroll
      PictureBox1.Size = New Size(64 * TrackBar1.Value, 64 * TrackBar1.Value)
      Panel1.AutoScrollMinSize = PictureBox1.Size
      Panel1_Resize(Panel1, EventArgs.Empty)
    End Sub
    
    Private Sub Panel1_Resize(sender As Object, e As EventArgs) Handles Panel1.Resize
      If PictureBox1.Width > Panel1.ClientSize.Width Then
        PictureBox1.Left = Panel1.AutoScrollPosition.X
      Else
        PictureBox1.Left = Panel1.ClientSize.Width / 2 - PictureBox1.Width / 2
      End If
    
      If PictureBox1.Height > Panel1.ClientSize.Height Then
        PictureBox1.Top = Panel1.AutoScrollPosition.Y
      Else
        PictureBox1.Top = Panel1.ClientSize.Height / 2 - PictureBox1.Height / 2
      End If
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a panel that is docked to the right side of a windows
It is in Winforms. I have a UserControl that is anchored TOP, BOTTOM and
In a C# form, I have a panel anchored all sides, and inside, a
I have a panel that is located at the bottom of the page. Inside
I have a panel anchored to top-left_BOTTOM of the form. there is a button
I have a rich panel that contains a form. This form is posted with
I have this Panel with 2 PictureBoxs inside, they are both Anchored too all
I have a panel that is docked to the left and another panel that
I have panel that is using group layout to organize some label. I want
I have a panel that draws alot of things. To make drawing effecient I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.