I have a windows form that starts at a designated size (not mazimized). I have a pictureBox1 control that zooms in & out. when I maximize my window and zoom in I need the pictureBox1 to return to it's original size upon clicking back to the original sized window. ANY THOUGHTS without using the anchor function?

private void pictureBox1_Click(object sender, EventArgs e)
        {
            if (this.WindowState == FormWindowState.Maximized)

                this.WindowState = FormWindowState.Normal;

This is very unclear, A better explanation would help to get a better answer but to resize a control you just set its width, and height via those properties

//example
pictureBox1.Width = 200;
pictureBox1.Height = 200;

Once I maximize my forms window and zoom in OR out, then, try to return to my forms normal size the picBox1 retains the same size as the last zoom. I need it upon returning to normal size to return to its starting size.

I don't mind if the pictureBox1 is reloaded to get the picBox to go back to its starting size.

I've tried

pictureBox1 = new PictureBox();

with no luck, also I tried

this.pictureBox1.Invalidate();

no luck there either (though it is used for drawing).

you where right, it was a simple fix that I overlooked. I was putting the code in the wrong place. Thanks!

Do you possibly know how to bind the zoom option so the in my 1st form (which is a set size x = 344, y= 620) the picture will stop zooming once it hits the edge of my form??

private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
        {
            //Sets X & Y cooridinates to lables while mouse is on picbox
            lblX.Text = "X: " + e.X.ToString();
            lblY.Text = "Y: " + e.Y.ToString();
        }

        private void pictureBox1_MouseLeave(object sender, EventArgs e)
        {
            lblX.Text = "";
            lblY.Text = "";
        }

        private void btnZoomIn_Click(object sender, EventArgs e)
        {
            //Sets + zoom by 40pixels
            pictureBox1.Height = pictureBox1.Height + 40;
            pictureBox1.Width = pictureBox1.Width + 40;
        }

        private void btnZoomOut_Click(object sender, EventArgs e)
        {
            //Sets - zoom ny 40pixels
            pictureBox1.Height = pictureBox1.Height - 40;
            pictureBox1.Width = pictureBox1.Width - 40;
        }

I'm not sure what method you are using to "zoom" your picture box. But I think you might want to find another method.

Thanks Diamonddrake,
I actually figured out my question right after I posted the last question.
SetBounds took good care of me :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.