다음을 통해 공유


Color.Transparent 속성

정의

시스템 정의 색을 가져옵니다.

public:
 static property System::Drawing::Color Transparent { System::Drawing::Color get(); };
public static System.Drawing.Color Transparent { get; }
static member Transparent : System.Drawing.Color
Public Shared ReadOnly Property Transparent As Color

속성 값

시스템 정의 색을 나타내는 Color입니다.

예제

다음 코드 예제를 사용 하는 방법에 설명 합니다 Transparent 속성입니다. 이 예제는 Windows Forms 함께 사용하도록 설계되었습니다. 및 Button2라는 Button1 두 개의 단추가 포함된 양식에 코드를 붙여넣습니다. 폼의 UseTransparentProperty 생성자에서 메서드를 호출합니다.

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." );
      }
   }
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.");
    }
}
Private Sub 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 ex As System.IO.FileNotFoundException
        MessageBox.Show("There was an error." _
        & "Make sure the image file path is valid.")
    End Try


End Sub

적용 대상