Cyotek Forums

Source Code => Source Code => Topic started by: Zeeshanef on May 30, 2024, 10:23:32 AM

Title: Scroll Behavior Adjustment After Drawing Rectangle on Image
Post by: Zeeshanef on May 30, 2024, 10:23:32 AM
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);
        }       
      }     
    }