This documentation is archived and is not being maintained.

Control.Scale Method (Single)

.NET Framework 1.1

Scales the control and any child controls to the specified ratio.

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

Parameters

ratio
The ratio by which to scale the control horizontally and vertically.

Remarks

This version of the Scale method uses the ratio parameter value to scale both the height and width of the control. To scale the height and width of the control independantly, use the version of the Scale method that takes two parameters.

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 and width of each control to 1.5 times its current size.

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

[C#] 
public void ScaleChildControlsEqually()
{
   // Resize all child controls to 1.5 
   // times their current size.
   for(int i = 0; i < this.Controls.Count; i++)
   {
      this.Controls[i].Scale(1.5f);
   }
}

[C++] 
public:
   void ScaleChildControlsEqually() {
      // Resize all child controls to 1.5
      // times their current size.
      for (int i = 0; i < this->Controls->Count; i++) {
         this->Controls->Item[i]->Scale(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: