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. .NET (Core and Framework)
  4. Error in Panel AutoScroll after rotating a Picturebox within that Panel in VB.Net

Error in Panel AutoScroll after rotating a Picturebox within that Panel in VB.Net

Scheduled Pinned Locked Moved .NET (Core and Framework)
helpcsharp
2 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.
  • U Offline
    U Offline
    User 9006357
    wrote on last edited by
    #1

    I have a panel of size width=150 pixel,height=100 pixel, backcolor=green with autoscroll is true. I also have a picturebox within that panel which contains a picture of size width=500 pixel, height=200 pixel. I also have a button, on clicking that button picturebox image rotates 90 degree clockwise. and according to that scrollbar values should change. but it is not. Here is my code Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim h, w PictureBox1.Image.RotateFlip(RotateFlipType.Rotate90FlipNone) PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize h = PictureBox1.Image.Height w = PictureBox1.Image.Width Panel1.HorizontalScroll.Maximum = 0 Panel1.HorizontalScroll.Visible = False Panel1.VerticalScroll.Maximum = 0 Panel1.VerticalScroll.Visible = False Panel1.AutoScroll = False Panel1.HorizontalScroll.Minimum = 0 Panel1.HorizontalScroll.Maximum = w - 1 Panel1.HorizontalScroll.Visible = True Panel1.HorizontalScroll.Value = 0 Panel1.VerticalScroll.Minimum = 0 Panel1.VerticalScroll.Maximum = h - 1 Panel1.VerticalScroll.Visible = True Panel1.VerticalScroll.Value = 0 Panel1.AutoScroll = True PictureBox1.Left = 0 PictureBox1.Top = 0 Panel1.Invalidate() End Sub My problem is: On form load both the scrollbars working perfectly. But after clicking the button picturebox rotates to 90 degrees, so picturebox's images's width and height values interchanges, so the scrollbars maximum values. But its not. After clicking the button first time vscrollbar does not go down after a certain value. This thing happens on odd number of clicking the button. On even number of clicking it works perfectly. This odd and even number problem also interchanges when the original picturebox image dimension interchanges. i.e. when picturebox image width=200, height=500, then hscrollbar creates the problem on odd number of button clicking.

    A 1 Reply Last reply
    0
    • U User 9006357

      I have a panel of size width=150 pixel,height=100 pixel, backcolor=green with autoscroll is true. I also have a picturebox within that panel which contains a picture of size width=500 pixel, height=200 pixel. I also have a button, on clicking that button picturebox image rotates 90 degree clockwise. and according to that scrollbar values should change. but it is not. Here is my code Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim h, w PictureBox1.Image.RotateFlip(RotateFlipType.Rotate90FlipNone) PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize h = PictureBox1.Image.Height w = PictureBox1.Image.Width Panel1.HorizontalScroll.Maximum = 0 Panel1.HorizontalScroll.Visible = False Panel1.VerticalScroll.Maximum = 0 Panel1.VerticalScroll.Visible = False Panel1.AutoScroll = False Panel1.HorizontalScroll.Minimum = 0 Panel1.HorizontalScroll.Maximum = w - 1 Panel1.HorizontalScroll.Visible = True Panel1.HorizontalScroll.Value = 0 Panel1.VerticalScroll.Minimum = 0 Panel1.VerticalScroll.Maximum = h - 1 Panel1.VerticalScroll.Visible = True Panel1.VerticalScroll.Value = 0 Panel1.AutoScroll = True PictureBox1.Left = 0 PictureBox1.Top = 0 Panel1.Invalidate() End Sub My problem is: On form load both the scrollbars working perfectly. But after clicking the button picturebox rotates to 90 degrees, so picturebox's images's width and height values interchanges, so the scrollbars maximum values. But its not. After clicking the button first time vscrollbar does not go down after a certain value. This thing happens on odd number of clicking the button. On even number of clicking it works perfectly. This odd and even number problem also interchanges when the original picturebox image dimension interchanges. i.e. when picturebox image width=200, height=500, then hscrollbar creates the problem on odd number of button clicking.

      A Offline
      A Offline
      Alan N
      wrote on last edited by
      #2

      The PictureBox is not perfect and if you turn on the borders you should be able to see that it does not resize itself correctly after the image has been rotated. In theory PictureBox.Refresh() or PictureBox.Invalidate() should sort out any problems but in my experience those methods do not help and the picturebox does not seem to know that the image has rotated. What I found helpful was to simply reassign the rotated image to the PictureBox.Image property. The strange alternate click issue with the Panel's scrollbars tends to happen if you muck about with the scroll properties. I came to the conclusion that Microsoft never meant us to change them! Alan.

      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