Color.Transparent 속성
시스템 정의 색을 가져옵니다.
네임스페이스: System.Drawing
어셈블리: System.Drawing(system.drawing.dll)
구문
‘선언
Public Shared ReadOnly Property Transparent As Color
‘사용 방법
Dim value As Color
value = Color.Transparent
public static Color Transparent { get; }
public:
static property Color Transparent {
Color get ();
}
/** @property */
public static Color get_Transparent ()
public static function get Transparent () : Color
속성 값
시스템 정의 색을 나타내는 Color입니다.
예제
다음 코드 예제에서는 Transparent 속성을 사용하는 방법을 보여 줍니다. 이 예제는 Windows Forms과 함께 사용해야 합니다. 코드를 Button1
및 Button2
라는 이름의 두 단추가 포함된 폼에 붙여넣습니다. 폼의 생성자에서 UseTransparentProperty
메서드를 호출합니다.
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
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 void UseTransparentProperty()
{
// Set up the PictureBox to display the entire image, and
// to cover the entire client area.
pictureBox1.set_SizeMode(PictureBoxSizeMode.StretchImage);
pictureBox1.set_Dock(DockStyle.Fill);
try {
// Set the Image property of the PictureBox to an image retrieved
// from the file system.
pictureBox1.set_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.set_Parent(pictureBox1);
button2.set_Parent(pictureBox1);
// Set the Color property of both buttons to transparent.
// With this setting the buttons assume the color of their
// parent.
button1.set_BackColor(Color.get_Transparent());
button2.set_BackColor(Color.get_Transparent());
}
catch (System.IO.FileNotFoundException exp) {
MessageBox.Show(("There was an error."
+ "Make sure the image file path is valid."));
}
} //UseTransparentProperty
플랫폼
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, 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에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.
버전 정보
.NET Framework
2.0, 1.1, 1.0에서 지원
.NET Compact Framework
2.0, 1.0에서 지원