Color.Transparent 属性 (System.Drawing)

您所在的位置:网站首页 transparent怎么理解 Color.Transparent 属性 (System.Drawing)

Color.Transparent 属性 (System.Drawing)

2024-07-05 08:33| 来源: 网络整理| 查看: 265

Color.Transparent 属性 参考 定义 命名空间: System.Drawing 程序集:System.Drawing.Primitives.dll 程序集:System.Drawing.dll 程序集:netstandard.dll Source:Color.cs Source:Color.cs Source:Color.cs

重要

一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,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

一个 Color,表示系统定义的颜色。

示例

下面的代码示例演示如何使用 Transparent 属性。 此示例旨在与 Windows 窗体 一起使用。 将代码粘贴到包含两个名为 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 适用于


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3