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 フォームで使用するように設計されています。 と Button2
という名前Button1
の 2 つのボタンを含むフォームにコードを貼り付けます。 フォームの 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
適用対象
GitHub で Microsoft と共同作業する
このコンテンツのソースは GitHub にあります。そこで、issue や pull request を作成および確認することもできます。 詳細については、共同作成者ガイドを参照してください。
.NET