Size 建構函式

定義

從指定的 Size,初始化 Point 結構的新執行個體。

多載

Size(Point)

從指定的 Size 結構,初始化 Point 結構的新執行個體。

Size(Int32, Int32)

從指定的維度,初始化 Size 結構的新執行個體。

Size(Point)

來源:
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 結構的新執行個體。

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.PointSize 建構函式和 System.Drawing.ContentAlignment 列舉。 若要執行此範例,請將此程式碼貼入 Windows Form,其中包含名為 Label1 的標籤,並在表單的建構函式中呼叫 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

適用於