Прочитать на английском

Поделиться через


Color.Transparent Свойство

Определение

Получает цвет, определенный системой.

public static System.Drawing.Color Transparent { get; }

Значение свойства

Объект 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.");
    }
}

Применяется к