Set the color of transparent properties in Panel C #

Source: Internet
Author: User

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.