Assembly : System.Drawing (dans system.drawing.dll)
SyntaxePublic 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
Valeur de la propriété
Color représentant une couleur définie par le système.
ExempleL'exemple de code suivant montre comment utiliser la propriété Transparent. Cet exemple est conçu pour être utilisé avec Windows Forms. Collez le code dans un formulaire qui contient deux boutons nommés Button1 et Button2. Appelez la méthode UseTransparentProperty dans le constructeur du formulaire.
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
Plates-formesWindows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile pour Pocket PC, Windows Mobile pour Smartphone, Windows Server 2003, Windows XP Édition Media Center, Windows XP Professionnel Édition x64, Windows XP SP2, Windows XP Starter Edition
Le .NET Framework ne prend pas en charge toutes les versions de chaque plate-forme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise.
Informations de version
Outils (masquer)
S'enregistrer
Liste des Membres
Qui est en ligne?
FAQ