Hi,

I have loaded a image in a picture box and also i zoomed in without any issue. when i zoom the picture box by keeping scroll bar at the top on issue found. But when i zoom the picture box by keeping the scroll bar at bottom Or at the center the Image starts load from bottom or center leaving space on the top. Again i move to top and pressed zoom in the image load from top.

In my code i am changing only x point of the picture box location and not changing the y point.

How could i load the image from the top when scroll bar at the bottom or center.

//sz1 is screen resolution of Primary System
sz1.Height +=50;
sz1.Width +=50;
Bitmap bp;


            bp = new Bitmap(sz1.Width/2, sz1.Height);
            bp.SetResolution(300, 300);
            g = Graphics.FromImage(bp);
            g.SmoothingMode = SmoothingMode.HighQuality;
            g.InterpolationMode = InterpolationMode.HighQualityBicubic;
            g.PixelOffsetMode = PixelOffsetMode.HighQuality;
           
            rect = new Rectangle(0, 0, sz1.Width / 2, sz1.Height);
            g.DrawImage(image, rect,0, 0, image.Width, image.Height, GraphicsUnit.Pixel);

            pictureBox1.Width  = rect.Width;
            pictureBox1.Height = rect.Height;
            
            if (zoominToolStripMenuItem1.Checked == true)
            {
                
                if (pictureBox1.Location.X > 0)
                {
                    #region set picturebox loction for zoomIn
//making picture of to sasrt from this loctation
                    pictureBox1.Location = new Point(pictureBox1.Location.X - 10, 48);
                    if (pictureBox1.Location.X<0)
                    pictureBox1.Location = new Point(0, 48);
                

            }
                else
                {
                    pictureBox1.Location = new Point(0, 48);
                    countw++;
                }
                    #endregion

            }
            else if (zoomOutToolStripMenuItem1.Checked == true)
            {
                #region set picturebox loction for zoomOut
                if (countw == 0)
                {
                    pictureBox1.Location = new Point(pictureBox1.Location.X + 10, 48);
                }
                else
                {
                    pictureBox1.Location = new Point(0, 48);
                    countw--;
                }
                #endregion
            }

            pictureBox1.Image = mybitmap=  bp;
            rect = new Rectangle(0, 0, 0, 0);

pls some one guide me on this... The scroll bar is a form scroll bar.

This article has been dead for over six months. Start a new discussion instead.