title: Enlarge form controls when the maximize button is clicked
body: <p>I have designed a WinForm in vb.NET with VS2017. I would now like to add a feature whereby the form has two sizes - the normal size it initially loads as and also a larger size that is triggered when the user clicks the maximize button on the form. If possible, I don't want the form to resize if a user drags its sides etc, I only want it to work if they click the maximize button. </p>
  
  <p>The form itself is laid out as shown, it is made up of a Panel that will always be anchored to the top, and a TabControl that will enlarge if the window is maximized. The TabControl is made up of 6 TabPages, all of which have GroupBoxes and Panels on them, and each GroupBox/Panel has a couple of Labels and TextBoxes. When it enlarges, I would like the size of the Labels and Textboxes to grow to the same percentage as the TabControl has been enlarged - basically everything in the TabControl grows by the same percentage  </p>
  
  <p><a href="https://i.stack.imgur.com/Rco3g.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Rco3g.jpg" alt="Form Layout"></a></p>
  
  <p>A possible solution I am thinking of is capturing the maximized and 'normal sized' form states (Normal Size being triggered at load time and if a user clicks to unmaximize the maximized form), and then looping through each control on each tab page and setting the style of each control to suit the desired larger layout.</p>
  
  <p>I have managed to capture the maximised and minimised events as follows:</p>
  
  <pre><code>Private Sub Form1_Resize(sender As Object, e As EventArgs) Handles Me.Resize
  
      If Me.WindowState = FormWindowState.Maximized Then
  
          Console.WriteLine("I have been maximised")
  
      End If
  
      If Me.WindowState = FormWindowState.Normal Then
          Console.WriteLine("I have been minimised")
      End If
  
  End Sub
  </code></pre>
  
  <p>I tried setting the Anchor Style of every control except the TabControl to "Top,Bottom,Right,Left", and then in the above subroutine, setting the TabControl AncorStyle to "Top,Bottom,Right,Left", but I had two problems with this:</p>
  
  <p>1) The following code didn't work correctly to set the AnchorStyle to "Top,Bottom,Right,Left"</p>
  
  <pre><code>TabControl1.Anchor = AnchorStyles.Top Or AnchorStyles.Bottom Or AnchorStyles.Left Or AnchorStyles.Right
  </code></pre>
  
  <p>The following was also unsuccessful:</p>
  
  <pre><code>TabControl1.Anchor = AnchorStyles.Top And AnchorStyles.Bottom And AnchorStyles.Left And AnchorStyles.Right
  </code></pre>
  
  <p>2) When I manually set the AnchorStyle of the TabControl to "Top,Bottom,Left,Right" in the Designer, and clicked Maximize when I ran the form, the form spreads out in an undesirable way, with the GroupBoxes on the TabPage overlapping, the text not changing its size in the Labels etc:</p>
  
  <p><a href="https://i.stack.imgur.com/5SKOg.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5SKOg.jpg" alt="enter image description here"></a></p>
  
  <p>Any help on this would be greatly appreciated</p>