Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27004

VS 2010 How do you move the position of a background image inside a PictureBox?

$
0
0
Hey guys,

I have a PictureBox control that will display an image that the end user specifies, and then position this image in the very center of the PictureBox (as it's background image). The width & height of these background images will vary, but they will always be smaller than the PictureBox.

What I would like to do is... each time that the user clicks button1, the background image position should move down 1 pixel inside the PictureBox. But the PictureBox itself should not move (otherwise I could solve this problem simply by adjust the PictureBox's top-margin inside it's parent container).

For example... I know that there is not a "top" property specifically for a PictureBox's background image, but if there was, then I would want to do something like this...

Code:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        If PictureBox1.BackgroundImage IsNot Nothing Then

            PictureBox1.BackgroundImage.Top += 1

        End If

    End Sub

So... any ideas how to accomplish something like this?

Viewing all articles
Browse latest Browse all 27004

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>