This documentation is archived and is not being maintained.

Color::Transparent Property

Gets a system-defined color.

Namespace:  System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)

public:
static property Color Transparent {
	Color get ();
}

Property Value

Type: System.Drawing::Color
A Color representing a system-defined color.

The following code example demonstrates how to use the Transparent property. This example is designed to be used with Windows Forms. Paste the code into a form that contains two buttons named Button1 and Button2. Call the UseTransparentProperty method in the form's constructor.

private:
   void UseTransparentProperty()
   {
      // Set up the PictureBox to display the entire image, and 
      // to cover the entire client area.
      PictureBox1->SizeMode = PictureBoxSizeMode::StretchImage;
      PictureBox1->Dock = DockStyle::Fill;
      try
      {
         // Set the Image property of the PictureBox to an image retrieved 
         // from the file system.
         PictureBox1->Image = Image::FromFile( "C:\\Documents and Settings\\All Users\\" 
         "Documents\\My Pictures\\Sample Pictures\\sunset.jpg" );

         // Set the Parent property of Button1 and Button2 to the  
         // PictureBox.
         Button1->Parent = PictureBox1;
         Button2->Parent = PictureBox1;

         // Set the Color property of both buttons to transparent.  
         // With this setting the buttons assume the color of their 
         // parent.
         Button1->BackColor = Color::Transparent;
         Button2->BackColor = Color::Transparent;
      }
      catch ( System::IO::FileNotFoundException^ ) 
      {
         MessageBox::Show( "There was an error." 
         "Make sure the image file path is valid." );
      }
   }

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

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

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0

XNA Framework

Supported in: 3.0, 2.0, 1.0
Show: