Bagikan melalui


Form.Opacity Properti

Definisi

Mendapatkan atau mengatur tingkat keburaman formulir.

public:
 property double Opacity { double get(); void set(double value); };
[System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.OpacityConverter))]
public double Opacity { get; set; }
[<System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.OpacityConverter))>]
member this.Opacity : double with get, set
Public Property Opacity As Double

Nilai Properti

Tingkat keburaman untuk formulir. Defaultnya adalah 1.00.

Atribut

Contoh

Contoh berikut menunjukkan cara membuat formulir yang ditampilkan dengan tingkat keburaman 75 persen. Ini membuat formulir baru yang diposisikan di tengah layar dengan properti yang Opacity diatur untuk mengubah tingkat keburaman formulir. Contoh ini juga mengatur Size properti untuk menyediakan formulir berukuran lebih besar daripada ukuran default formulir.

Contoh ini mengasumsikan bahwa metode dipanggil CreateMyOpaqueForm 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 Opacity memungkinkan Anda menentukan tingkat transparansi untuk formulir dan kontrolnya. Ketika properti ini diatur ke nilai kurang dari 100 persen (1,00), seluruh formulir, termasuk batas, dibuat lebih transparan. Mengatur properti ini ke nilai 0 persen (0,00) membuat formulir benar-benar tidak terlihat. Anda dapat menggunakan properti ini untuk memberikan tingkat transparansi yang berbeda atau untuk memberikan efek seperti phasing formulir masuk atau tidak terlihat. Misalnya, Anda dapat membuat fase formulir ke tampilan dengan mengatur Opacity properti ke nilai 0 persen (0,00) dan secara bertahap meningkatkan nilai hingga mencapai 100 persen (1,00).

Opacity berbeda dari transparansi yang disediakan oleh TransparencyKey, yang hanya membuat formulir dan kontrolnya benar-benar transparan jika warnanya sama dengan nilai yang ditentukan dalam TransparencyKey properti.

Properti ini tidak didukung ketika RightToLeftLayout adalah true.

Properti Opacity tergantung pada API Windows Berlapis. Untuk informasi selengkapnya, lihat Windows berlapis.

Berlaku untuk

Lihat juga