Form.Opacity プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

/** @property */ public double get_Opacity () /** @property */ public void set_Opacity (double value)
フォームの不透明度。既定値は 1.00 です。

Opacity プロパティを使用すると、フォームとそのコントロールの透明度を指定できます。このプロパティが 100% (1.00) 未満の値に設定されると、境界線を含むフォーム全体の透明度が上がります。このプロパティが 0% (0.00) の値に設定されると、フォームは完全に見えなくなります。このプロパティを使用して、さまざまな透明度を指定することや、フォームを徐々に見えるようにしたり見えなくなるようにしたりする効果を指定できます。たとえば、フォームが徐々に見えるようにするためには、Opacity プロパティを 0% (0.00) の値に設定し、100% (1.00) に達するまで値を徐々に増やしていきます。
Opacity は、TransparencyKey で指定される透明度とは異なります。TransparencyKey プロパティの場合は、フォームおよびコントロールの色がこのプロパティで指定した色と同じ場合に、それらのフォームおよびプロパティを完全に透明にするだけです。
RightToLeftLayout が true の場合、このプロパティはサポートされません。
Opacity プロパティは、Windows 2000 で導入されたレイヤード ウィンドウ API に依存しています。詳細については、http://msdn.microsoft.com にあるプラットフォーム SDK に関するドキュメントの「Layered Windows: A New Way to Use Translucency and Transparency Effects in Windows Applications」を参照してください。
Windows 2000, Windows 2000 Professional, Windows 2000 Server, Windows 2000 Advanced Server, Windows XP Home Edition, Windows XP Professional x64 Edition, Windows Server 2003 プラットフォームメモ : これらのプラットフォームはレイヤード ウィンドウ API をサポートしています。このプロパティは、レイヤード ウィンドウを表示できないプラットフォームでは無効です。また、一部のディスプレイ ドライバはレイヤ表示をサポートしていません。

不透明度 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 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.Opacity プロパティのページへのリンク