Form.Size Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan atau mengatur ukuran formulir.
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
Nilai Properti
Size yang mewakili ukuran formulir.
Contoh
Contoh berikut menunjukkan cara membuat formulir yang ditampilkan dengan tingkat keburaman 75 persen. Contoh kode membuat formulir baru yang diposisikan di tengah layar dengan properti diatur Opacity untuk mengubah tingkat keburaman formulir. Kode contoh juga mengatur Size properti untuk menyediakan formulir berukuran lebih besar daripada ukuran default formulir. Contoh ini mengharuskan metode yang ditentukan dalam contoh ini dipanggil dari formulir lain dalam penanganan aktivitas atau metode lain.
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
Keterangan
Properti ini memungkinkan Anda mengatur tinggi dan lebar (dalam piksel) formulir secara bersamaan alih-alih mengatur Height properti dan Width satu per satu. Jika Anda ingin mengatur ukuran dan lokasi formulir, Anda dapat menggunakan DesktopBounds properti untuk mengukur dan menemukan formulir berdasarkan koordinat desktop atau menggunakan Bounds properti Control kelas untuk mengatur ukuran dan lokasi formulir berdasarkan koordinat layar.
Nota
Nilai maksimum properti ini dibatasi oleh resolusi layar tempat formulir berjalan. Nilai tidak boleh lebih besar dari 12 piksel di setiap dimensi layar (horizontal + 12 dan vertikal + 12).
Nota
Pada perangkat Pocket PC, Anda dapat membuat jendela yang dapat diubah ukurannya dengan mengatur FormBorderStyleNone ke dan menghapus kontrol apa pun MainMenu . Di perangkat SmartPhone, Anda tidak pernah dapat mengubah ukuran Form - perangkat akan selalu mengisi seluruh layar.