You can resize controls at run time by specifying the Size and Location in a Rectangle object in code and assigning the Rectangle to the Bounds property of the control.
To size a control programmatically
[Visual Basic] Private Sub MakeSizedButton() Dim rect1 as Rectangle Dim button1 as Button Set rect1 = new Rectangle 'Use the SetBounds method to set the X,Y,Width, and Height of the Rectangle. rect1.SetBounds(75, 23, 100, 50) [C#] private void MakeSizedButton() { Rectangle rect1 = new Rectangle (50, 100, 75, 23);
[Visual Basic] Set button1.Bounds = rect1 End Sub [C#] button1.Bounds = rect1; }
Note Alternatively, you can also use the Size and Location properties to independently specify the size and location of the control respectively. For more information about the Location property, see Positioning Controls on Win Forms.
[Visual Basic] MakeSizedButton [C#] MakeSizedButton();
Control Manipulation on Win Forms | Controls by Category | Adding Controls to Win Forms | Anchoring Controls on Win Forms | Docking Controls on Win Forms | Layering Objects on Win Forms | Setting the Tab Order on Win Forms | Working with Individual Controls | Controls You can Use on Win Forms | Control Technologies and Where to Use Them | Win Form Controls by Function