Form.Size プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文
フォームのサイズを表す Size。
このプロパティを使用すると、フォームの高さと幅をピクセル単位で同時に設定できます。Height プロパティと Width プロパティを個別に設定する必要はありません。フォームのサイズと位置を設定する場合は、DesktopBounds プロパティを使用して、デスクトップ座標に基づいてそれらの値を設定するか、Control クラスの Bounds プロパティを使用して、画面座標に基づいて設定できます。
メモ |
---|
このプロパティの最大値は、フォームを実行する画面の解像度によって制限されます。設定できる値は、画面の水平解像度 + 12 以下、および垂直解像度 + 12 以下です。 |
不透明度 75% で表示されるフォームを作成する方法を次のコード例に示します。このコード例では、新しいフォームを画面の中央に作成し、Opacity プロパティを設定してフォームの不透明度を変更します。また、既定のサイズのフォームより大きなフォームを作成するように、Size プロパティも設定します。この例は、この例で定義されているメソッドが別のフォームからイベント ハンドラか他のメソッドで呼び出されることを前提にしています。
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
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: 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.set_Text("My Form"); // Set the opacity to 75%. form2.set_Opacity(0.75); // Size the form to be 300 pixels in height and width. form2.set_Size(new Size(300, 300)); // Display the form in the center of the screen. form2.set_StartPosition(FormStartPosition.CenterScreen); // Display the form as a modal dialog box. form2.ShowDialog(); } //CreateMyOpaqueForm
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- Form.Size プロパティのページへのリンク