Color.Transparent 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得系統定義的色彩。
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 搭配使用。 將程式代碼貼到表單中,其中包含兩個名為 Button1
和的 Button2
按鈕。 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