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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Anyway to set picturebox control to always be center screen???

Anyway to set picturebox control to always be center screen???

Scheduled Pinned Locked Moved Visual Basic
tutorialquestion
3 Posts 3 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.
  • J Offline
    J Offline
    Joey Picerno
    wrote on last edited by
    #1

    Does anyone know how to make a picturebox control where it is always centered on the form. I have an MDI parent form that is always maximized but depending on the size of the monitor the picture box in the middle isnt always in the middle. I need a way to set this picture box to always be in the center of the form. Thank you.....

    N J 2 Replies Last reply
    0
    • J Joey Picerno

      Does anyone know how to make a picturebox control where it is always centered on the form. I have an MDI parent form that is always maximized but depending on the size of the monitor the picture box in the middle isnt always in the middle. I need a way to set this picture box to always be in the center of the form. Thank you.....

      N Offline
      N Offline
      nlarson11
      wrote on last edited by
      #2

      Private Sub Form2_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize If Me.WindowState <> FormWindowState.Minimized Then With PictureBox1 .Left = (Me.ClientRectangle.Width / 2) - (.Width / 2) .Top = (Me.ClientRectangle.Height / 2) - (.Height / 2) End With end if End Sub

      1 Reply Last reply
      0
      • J Joey Picerno

        Does anyone know how to make a picturebox control where it is always centered on the form. I have an MDI parent form that is always maximized but depending on the size of the monitor the picture box in the middle isnt always in the middle. I need a way to set this picture box to always be in the center of the form. Thank you.....

        J Offline
        J Offline
        Johan Hakkesteegt
        wrote on last edited by
        #3

        I do the same thing with a label. I first centered it on the form through the format menu, and then I just anchored it on all four sides. The text is centered both vertically and horizontally in the label. As the font size won't change it doesn't matter that the label gets stretched. I don't know however what happens to the image in a picture box, but otherwise it should work the same way. Johan

        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