Form.Size 屬性

定義

取得或設定表單的大小。

public:
 property System::Drawing::Size Size { System::Drawing::Size get(); void set(System::Drawing::Size value); };
public System.Drawing.Size Size { get; set; }
member this.Size : System.Drawing.Size with get, set
Public Property Size As Size

屬性值

Size,代表表單的大小。

範例

下列範例示範如何建立以不透明度層級 75% 顯示的表單。 此範例程式碼會建立位於畫面中央的新表單,並將 Opacity 屬性設定為變更表單的不透明度層級。 此範例程式碼也會設定 Size 屬性,以提供大於表單預設大小的表單。 這個範例需要從事件處理常式或其他方法的另一個表單呼叫在此範例中定義的方法。

private:
   void CreateMyOpaqueForm()
   {
      // Create a new form.
      Form^ form2 = gcnew Form;

      // Set the text displayed in the caption.
      form2->Text = "My Form";

      // Set the opacity to 75%.
      form2->Opacity = .75;

      // Size the form to be 300 pixels in height and width.
      form2->Size = System::Drawing::Size( 300, 300 );

      // Display the form in the center of the screen.
      form2->StartPosition = FormStartPosition::CenterScreen;

      // Display the form as a modal dialog box.
      form2->ShowDialog();
   }
private void CreateMyOpaqueForm()
{
   // Create a new form.
   Form form2 = new Form();
   // Set the text displayed in the caption.
   form2.Text = "My Form";
   // Set the opacity to 75%.
   form2.Opacity = .75;
   // Size the form to be 300 pixels in height and width.
   form2.Size = new Size(300,300);
   // Display the form in the center of the screen.
   form2.StartPosition = FormStartPosition.CenterScreen;

   // Display the form as a modal dialog box.
   form2.ShowDialog();
}
Private Sub CreateMyOpaqueForm()
   ' Create a new form.
   Dim form2 As New Form()
   ' Set the text displayed in the caption.
   form2.Text = "My Form"
   ' Set the opacity to 75%.
   form2.Opacity = 0.75
   ' Size the form to be 300 pixels in height and width.
   form2.Size = New Size(300, 300)
   ' Display the form in the center of the screen.
   form2.StartPosition = FormStartPosition.CenterScreen

   ' Display the form as a modal dialog box.
   form2.ShowDialog()
End Sub

備註

此屬性可讓您同時以圖元為單位設定高度和寬度 (,) 表單,而不是個別設定 HeightWidth 屬性。 如果您想要設定表單的大小和位置,您可以使用 DesktopBounds 屬性來根據桌面座標來調整及尋找表單的大小,或使用 Bounds 類別的 Control 屬性,根據螢幕座標來設定表單的大小和位置。

注意

此屬性的最大值受限於表單執行所在畫面的解析度。 值不能超過每個螢幕尺寸的 12 圖元, (水準 + 12 和垂直 + 12) 。

注意

在 Pocket PC 裝置上,您可以將 設定 FormBorderStyleNone 並移除任何 MainMenu 控制項,以建立可調整大小的視窗。 在 SmartPhone 裝置上,您永遠不能調整大小 Form , 它一律會填滿整個畫面。

適用於

另請參閱