title: Resize rectangle with form Size in real time?
body: <p>Here is the following rectangle below:</p>
  
  <p><a href="https://i.stack.imgur.com/4bc3N.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4bc3N.png" alt="enter image description here"></a></p>
  
  <p>When I resize the form, I need this rectangle to match the size of the form.</p>
  
  <p>When changing the width of the rectangle, do not interfere with its visibility within the form.</p>
  
  <p>I'm using the following:</p>
  
  <p>Note:</p>
  
  <p>I did the rectangle manually, but if you have rectangle ready, better yet!</p>
  
  <pre><code>public Form1()
  {
      InitializeComponent();
      this.Paint += Form1_Paint;
      this.rectangles = new Dictionary&lt;string, Rectangle&gt;();
      this.sizeScreen = this.Size;
      this.sizeRectangles = new Size(8, 8);
      this.brush = new SolidBrush(Color.Red);
      FillLeft();
      FillRight();
      FillUp();
      FillDown();
  }
  
  private Size sizeScreen;
  private Size sizeRectangles;
  private SolidBrush brush;
  private Dictionary&lt;string, Rectangle&gt; rectangles;
  private void FillLeft()
  {
      Rectangle rectangle = new Rectangle()
      {
          Height = this.sizeScreen.Height,
          Width = this.sizeRectangles.Width,
          X = 0,
          Y = this.sizeRectangles.Height
      };
      this.rectangles.Add("left", rectangle);
  }
  private void FillRight()
  {
      Rectangle rectangle = new Rectangle()
      {
          Height = this.sizeScreen.Height,
          Width = this.sizeRectangles.Width,
          X = this.sizeScreen.Width - (this.sizeRectangles.Width * 5),
          Y = this.sizeRectangles.Height
      };
      this.rectangles.Add("right", rectangle);
  }
  private void FillUp()
  {
      Rectangle rectangle = new Rectangle()
      {
          Height = this.sizeRectangles.Height,
          Width = this.sizeScreen.Width,
          X = 0,
          Y = this.sizeRectangles.Height
      };
      this.rectangles.Add("up", rectangle);
  }
  private void FillDown()
  {
      Rectangle rectangle = new Rectangle()
      {
          Height = this.sizeRectangles.Height,
          Width = this.sizeScreen.Width,
          X = 0,
          Y = this.sizeScreen.Height - (this.sizeRectangles.Height * 11)
      };
      this.rectangles.Add("down", rectangle);
  }
  
  private void Form1_Paint(object sender, PaintEventArgs e)
  {
      for (int i = 0; i &lt; this.rectangles.Count; i++)
      {
          e.Graphics.FillRectangles(this.brush, this.rectangles.Values.ToArray());
      }
  }
  </code></pre>
  
  <p>I want to set the rectangle on the form when it is resized</p>
  
  <p>This is the way I'm creating the rectangle, but it does not stay right on the screen, to resize it I do not know</p>