語言

Size 建構函式

定義

從指定的Size結構中初始化一個新的實例Point。

多載

名稱 Description
Size(Point)

從指定的Size結構初始化一個新的結構實例Point。

Size(Int32, Int32)

初始化指定維度結構的新實例 Size 。

Size(Point)

來源:
Size.cs
來源:
Size.cs
來源:
Size.cs
來源:
Size.cs
來源:
Size.cs

從指定的Size結構初始化一個新的結構實例Point。

public:
 Size(System::Drawing::Point pt);
public Size(System.Drawing.Point pt);
new System.Drawing.Size : System.Drawing.Point -> System.Drawing.Size
Public Sub New (pt As Point)

參數

pt
Point

Point初始化此Size結構的基礎。

適用於

Size(Int32, Int32)

來源:
Size.cs
來源:
Size.cs
來源:
Size.cs
來源:
Size.cs
來源:
Size.cs

初始化指定維度結構的新實例 Size 。

public:
 Size(int width, int height);
public Size(int width, int height);
new System.Drawing.Size : int * int -> System.Drawing.Size
Public Sub New (width As Integer, height As Integer)

參數

width
Int32

新的 Size.

height
Int32

新的 Size.

範例

以下程式碼範例示範如何使用 Point.Point and Size 構造子與 System.Drawing.ContentAlignment 列舉。 要執行此範例,將此程式碼貼入包含標籤為 Label1 的 Windows 表單,並在表單的建構子中呼叫 InitializeLabel1 方法。

void InitializeLabel1()
{
   // Set a border.
   Label1->BorderStyle = BorderStyle::FixedSingle;
   
   // Set the size, constructing a size from two integers.
   Label1->Size = System::Drawing::Size( 100, 50 );
   
   // Set the location, constructing a point from a 32-bit integer
   // (using hexadecimal).
   Label1->Location = Point(0x280028);
   
   // Set and align the text on the lower-right side of the label.
   Label1->TextAlign = ContentAlignment::BottomRight;
   Label1->Text = "Bottom Right Alignment";
}
private void InitializeLabel1()
{
    // Set a border.
    Label1.BorderStyle = BorderStyle.FixedSingle;

    // Set the size, constructing a size from two integers.
    Label1.Size = new Size(100, 50);

    // Set the location, constructing a point from a 32-bit integer
    // (using hexadecimal).
    Label1.Location = new Point(0x280028);

    // Set and align the text on the lower-right side of the label.
    Label1.TextAlign = ContentAlignment.BottomRight;
    Label1.Text = "Bottom Right Alignment";
}
Private Sub InitializeLabel1()

    ' Set a border.
    Label1.BorderStyle = BorderStyle.FixedSingle

    ' Set the size, constructing a size from two integers.
    Label1.Size = New Size(100, 50)

    ' Set the location, constructing a point from a 32-bit integer
    ' (using hexadecimal).
    Label1.Location = New Point(&H280028)

    ' Set and align the text on the lower-right side of the label.
    Label1.TextAlign = ContentAlignment.BottomRight
    Label1.Text = "Bottom Right Alignment"
End Sub

適用於