Scroll Behavior Adjustment After Drawing Rectangle on Image

Started by Zeeshanef, May 30, 2024, 10:23:32 AM

Previous topic - Next topic

Zeeshanef

I am creating a rectangle overlay on an image by a Button click using the code below. My query is, after painting the rectangle, what's the correct method to automatically scroll to the image so that the painted rectangle is visible in the center of the available container?

private void ImageBox1_Paint(object sender, PaintEventArgs e)
    {             
      if (drawRectangle)
      {
        using (Brush brush = new SolidBrush(Color.FromArgb(64, 1, 165, 220)))
        {
          Rectangle OffSetRect = imageBox1.GetOffsetRectangle(RectDraw);
          e.Graphics.FillRectangle(brush, OffSetRect);
        }       
      }     
    }