Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 4
Form Class
Form Properties
 Opacity Property
Collapse All/Expand All Collapse All
.NET Framework Class Library
Form..::.Opacity Property

Gets or sets the opacity level of the form.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)
Visual Basic
<TypeConverterAttribute(GetType(OpacityConverter))> _
Public Property Opacity As Double
C#
[TypeConverterAttribute(typeof(OpacityConverter))]
public double Opacity { get; set; }
Visual C++
[TypeConverterAttribute(typeof(OpacityConverter))]
public:
property double Opacity {
    double get ();
    void set (double value);
}
F#
[<TypeConverterAttribute(typeof(OpacityConverter))>]
member Opacity : float with get, set

Property Value

Type: System..::.Double
The level of opacity for the form. The default is 1.00.

The Opacity property enables you to specify a level of transparency for the form and its controls. When this property is set to a value less than 100 percent (1.00), the entire form, including borders, is made more transparent. Setting this property to a value of 0 percent (0.00) makes the form completely invisible. You can use this property to provide different levels of transparency or to provide effects such as phasing a form in or out of view. For example, you can phase a form into view by setting the Opacity property to a value of 0 percent (0.00) and gradually increasing the value until it reaches 100 percent (1.00).

Opacity differs from the transparency provided by the TransparencyKey, which only makes a form and its controls completely transparent if they are the same color as the value specified in the TransparencyKey property.

This property is not supported when RightToLeftLayout is true.

The Opacity property depends on the Layered Windows API that was introduced with Windows 2000. For more information, see the "Layered Windows: A New Way to Use Translucency and Transparency Effects in Windows Applications" in the Platform SDK documentation at http://msdn.microsoft.com.

Windows 2000, Windows 2000 Professional, Windows 2000 Server, Windows 2000 Advanced Server, Windows XP Home Edition, Windows XP Professional x64 Edition, Windows Server 2003 Platform Note: Supports the Layered Windows API. This property has no effect on platforms that cannot display layered windows. In addition, some display drivers do not support layering.

The following code example demonstrates how to create a form that is displayed with an opacity level of 75 percent. The code example creates a new form that is positioned in the center of the screen with an Opacity property set to change the opacity level of the form. The code example also sets the Size property to provide a larger sized form than the default size of the form. This code example was written under the assumption that the method defined in this example is called from another form in an event handler or other method.

Visual Basic
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
C#
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();
}
Visual C++
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();
   }

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Non taskbar icon      Koopakiller   |   Edit   |   Show History
Set the ShowInTaskbar-property of false
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.showintaskbar%28v=vs.100%29.aspx

and Opacity of 0, and you have a hidden form.
Tags What's this?: Add a tag
Flag as ContentBug
Setting Form.Opacity to zero      Raspin   |   Edit   |   Show History
It causes form stay invisible on screen but still visible in the task bar if set opacity to zero: this.Opacity = 0;
Tags What's this?: Add a tag
Flag as ContentBug
Does the form still show in the task bar?      Chad Sowald   |   Edit   |   Show History
If I set opacity = 0, will the form still show up in the Windows task bar?
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker