[Emphasis on transparency] set the color of the transparent attribute C # in the Panel.

Source: Internet
Author: User

Set the color of transparent properties in Panel C #

Unfortunately, the control is notColor. FromArgb transparent billing settings

The implementation method of transparent Panel. Generally, you only need to set the backcolor to transparent. However, the color of the panel is the same as that of the form or parent panel. This is usually not what we need.

In this case, we can use another method, panel1.BackColor = Color. FromArgb (65,204,212,230). By adjusting the Color value, the panel is transparent and the effects of different colors are achieved.

The color in the. NET Framework is based on four components: transparency, red, green, and blue. Each component is a byte and can be set between 0--255.
The Color structure represents the Color. When classes and methods are applied to the Color, they act on an instance of the Color structure. the Color structure discloses 140 named colors through the declarative attributes. These attributes return pre-created Color objects.
Color newColor = Color. Red;

Another way to create a Color instance is to call staticFromArgbMethod, which has four overload methods.
1. Create a Color instanceParametersFour Color Components
Color c = Color.FromArgb(100,200,200,200 );
1stParametersFor transparency (alpha)ParametersAnd then red, green, and blue.
2. Only red, green, and blue primary colors are accepted. The transparency is set to the default value, that is, completely opaque.
Color c = Color.FromArgb(200,200,200 );
3. Create a new Color instance from a current Color object and modify only the transparency component.
Color c = Color.FromArgb(100, Color. PowderBlue );
4. Create a Color instance with a combined integer in the form of AARRGGBB
Color c = Color.FromArgb(0x64C8C8FF );

You can also call the static FromKnownColor method to create a Color object. It accepts the KnownColor enumerated valueParameters.
Color c = Color. FromKnownColor (KnownColor. PowderBlue );

Another way is to call the static FromName method, which accepts a stringParametersThe string must contain the name of the KnownColor enumerated value.
Color c = Color. FromName ("PowderBlue ");

The Color structure has four read-only attributes: A, R, G, and B. You can use these attributes to extract various components and blend them into new colors.
Other non-static attributes include:
The value of IsNamedColor Boolean. If the color value is in the 140 named colors, the value is true; otherwise, the value is false.
The value of IsKnownColor Boolean. If the color value is one of the colors enumerated by KnownColors, the value is true.
IsSystemColor Boolean value. If the color value is a temporary value of the SystemColors class, the value is true.

System color
The SystemColors class encapsulates 26 system colors. This class can use colors through static attributes.
Color c = SystemColors. WindowText;

The KnownColor enumeration contains 26 Color values of the SystemColors class and 140 Color values exposed by the static properties of the Color structure.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.