Dynamically resizing controls when form changes size?

Does anyone know how to resize controls within a form when a user changes the size of the form. I want the controls to resize proportionately as the form size changes.
BlakeMcKennaAsked:
Who is Participating?
 
MacroShadowConnect With a Mentor Commented:
Set up your form and all of its controls, based on the above example set the location, size and anchor  of each control.
0
 
MacroShadowCommented:
Take a look at the .Anchor property of pretty much any control. This resizes the control any time the parent is resized. The way I learned how to use the .Anchor properly was I started a blank project and added just about every control and used differnet anchors like: Left and Right or Left and Top, and see what happened when I maximized my form.

Edit - Start a new project and add a Datagridview, Button, and Textbox. Then press F7 and add this:

Option Strict On
Option Explicit On
Public Class Form1

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        With Me
            .Text = "Anchor Test"
            .Size = New Size(300, 300)
        End With
        With DataGridView1
            .Location = New Point(13, 13)
            .Size = New Size(259, 208)
            .Anchor = AnchorStyles.Left Or AnchorStyles.Right Or AnchorStyles.Top Or AnchorStyles.Bottom
        End With
        With Button1
            .Location = New Point(12, 227)
            .Size = New Size(75, 23)
            .Anchor = AnchorStyles.Bottom Or AnchorStyles.Left
        End With
        With TextBox1
            .Location = New Point(93, 229)
            .Size = New Size(179, 20)
            .Anchor = AnchorStyles.Bottom Or AnchorStyles.Right Or AnchorStyles.Left
        End With
    End Sub
End Class

Open in new window


http://www.vbforums.com/showthread.php?689453-Resize-the-controls-on-windows-form-when-the-form-is-maximed-or-in-normal-state&p=4226571&viewfull=1#post4226571
0
 
BlakeMcKennaAuthor Commented:
What about the Form_Resize() Event?
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
MacroShadowCommented:
What about it?
0
 
BlakeMcKennaAuthor Commented:
I guess not!

What about controls within controls?
0
 
MacroShadowCommented:
Same logic applies.

Use the .Anchor property of the parent control, and within it the .Anchor property of the child control.
0
 
BlakeMcKennaAuthor Commented:
Sorry but I'm not following! I have attached an image of the Form I need to do this with. Can you be more specific plz?
Screenshot.jpg
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.