Udostępnij za pośrednictwem


How to: Create Transparent Windows Forms

With Microsoft Windows XP, you can control the opacity of windows that are displayed. To make a form more transparent, adjust its Opacity property.

Note

As transparent forms are only supported in Windows 2000 or later, Windows Forms will be completely opaque when run on older operating systems, such as Windows 98, regardless of the value set for the Opacity property.

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

To control the opacity of Windows Forms

  • In the Properties window, set the Opacity property to a value between 0.0 (complete transparency) and 1.0 (complete opacity).

To control the opacity of Windows Forms programmatically

  • In a method, set the Opacity property to a percentage between 0.0 (complete transparency) and 1.0 (complete opacity). The Opacity property is a Double value type.

    Public Sub MakeSeeThru()
       frmTransparentForm.Opacity = 0.83
    End Sub
    
    public void MakeSeeThru()
    {
       frmTransparentForm.Opacity = 0.83;
    }
    
    public:
       void MakeSeeThru()
       {
          frmTransparentForm->Opacity = 0.83;
       }
    

See Also

Tasks

How to: Give Your Control a Transparent Background

How to: Draw with Opaque and Semitransparent Brushes

How to: Draw Opaque and Semitransparent Lines

Reference

Windows Forms Overview

Other Resources

Dialog Boxes in Windows Forms

Changing the Appearance of Windows Forms