Color.Transparent プロパティ
アセンブリ: System.Drawing (system.drawing.dll 内)


Transparent プロパティを使用する方法を次のコード例に示します。この例は、Windows フォームでの使用を意図してデザインされています。Button1 と Button2 という名前の 2 つのボタンが配置されているフォームにコードを貼り付けます。フォームのコンストラクタで 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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からColor.Transparent プロパティを検索する場合は、下記のリンクをクリックしてください。

- Color.Transparent プロパティのページへのリンク