Export (0) Print
Expand All

Control.Scale Method (Single, Single)

.NET Framework 1.1

Scales the control and any child controls by the specified horizontal and vertical ratios.

[Visual Basic]
Overloads Public Sub Scale( _
   ByVal dx As Single, _
   ByVal dy As Single _
)
[C#]
public void Scale(
 float dx,
 float dy
);
[C++]
public: void Scale(
 float dx,
 float dy
);
[JScript]
public function Scale(
   dx : float,
 dy : float
);

Parameters

dx
The ratio by which to scale the control horizontally.
dy
The ratio by which to scale the control vertically.

Remarks

This version of the Scale method uses the dx and dy parameter values to scale the height and width of the control independently. To keep the height and width of the control in proportion to their current size, use the version of the Scale method that takes one parameter.

The ScaleCore method is called by the Scale methods to scale the control. You should override the ScaleCore method to ensure that your code is executed when either of the Scale methods is called.

Example

[Visual Basic, C#, C++] The following example resizes the child controls of a Form using the Scale method. This example scales the height of each control to 1.5 times its current size while the current width of each control is maintained.

[Visual Basic] 
Public Sub ScaleChildControls()
   ' Resize all child controls to 1.5 times their current
   ' height while, maintaining their current width.
   Dim i As Integer
   For i = 0 To (Me.Controls.Count) - 1
      Me.Controls(i).Scale(1F, 1.5F)
   Next i
End Sub 

[C#] 
public void ScaleChildControls()
{
   // Resize all child controls to 1.5 times their current
   // height while, maintaining their current width.
   for(int i = 0; i < this.Controls.Count; i++)
   {
      this.Controls[i].Scale(1.0f, 1.5f);
   }
}

[C++] 
public:
   void ScaleChildControls() {
      // Resize all child controls to 1.5 times their current
      // height while, maintaining their current width.
      for (int i = 0; i < this->Controls->Count; i++) {
         this->Controls->Item[i]->Scale(1.0f, 1.5f);
      }
   }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Control Class | Control Members | System.Windows.Forms Namespace | Control.Scale Overload List | ScaleCore

Show:
© 2014 Microsoft