C # modify the Panel border color using winform

Source: Internet
Author: User
It cannot be directly modified in the attribute panel. You can re-paint in the paint event. Private   Void Panelease paint ( Object Sender, painteventargs E)
{
Controlpaint. drawborder (E. Graphics,
This . Panel1.clientrectangle,
Color. lightseagreen, // 7f9db9
1 ,
Buttonborderstyle. Solid,
Color. lightseagreen,
1 ,
Buttonborderstyle. Solid,
Color. lightseagreen,
1 ,
Buttonborderstyle. Solid,
Color. lightseagreen,
1 ,
Buttonborderstyle. Solid );
}

URL: http://greatverve.cnblogs.com/archive/2011/07/21/panel-border-color.html
Appendix: C # RGB and hexadecimal color conversion method

# Region [color: hexadecimal to RGB]
/// <Summary>
/// [Color: hexadecimal to RGB]
/// </Summary>
/// <Param name = "strcolor"> set the hexadecimal color [returns RGB] </param>
/// <Returns> </returns>
Public static system. Drawing. Color colorhx16torgb (string strhxcolor)
{
Try
{
If (strhxcolor. Length = 0)
{// If it is null
Return System. Drawing. color. froma #000000; // set it to black
}
Else
{// Convert the color
Return System. drawing. color. fromargb (system. int32.parse (strhxcolor. substring (1, 2), system. globalization. numberstyles. allowhexspecifier), system. int32.parse (strhxcolor. substring (3, 2), system. globalization. numberstyles. allowhexspecifier), system. int32.parse (strhxcolor. substring (5, 2), system. globalization. numberstyles. allowhexspecifier ));
}
}
Catch
{// Set to black
Return System. Drawing. color. froma #000000;
}
}
# Endregion

 


# Region [color: Convert RGB to hexadecimal]
/// <Summary>
/// [Color: Convert RGB to hexadecimal]
/// </Summary>
/// <Param name = "R"> Red int </param>
/// <Param name = "G"> green int </param>
/// <Param name = "B"> blue int </param>
/// <Returns> </returns>
Public static string colorrgbtohx16 (int r, int g, int B)
{
Return System. Drawing. colortranslator. tohtml (system. Drawing. color. fromargb (R, G, B ));
}
# Endregion

 

Also:


Private string tohexcolor (color)
{
String r = convert. tostring (color. R, 16 );
If (r = "0 ")
R = "00 ";
String G = convert. tostring (color. G, 16 );
If (G = "0 ")
G = "00 ";
String B = convert. tostring (color. B, 16 );
If (B = "0 ")
B = "00 ";
String hexcolor = "#" + R + G + B;
Return hexcolor;
}

 

Public String forecolor

{

Set

{

// Value = # ab364f

Int r = convert. toint32 ("0x" + value. substring (1, 2), 16 );

Int G = convert. toint32 ("0x" + value. substring (3, 2), 16 );

Int B = convert. toint32 ("0x" + value. substring (5, 2), 16 );

Txturl. forecolor = system. Drawing. color. fromargb (R, G, B );

}

}

Return the JS color of the cyclical gradient with an incremental number. Code

Function GCL (I ){
VaR F = parseint (I % 15)/5 );
I = I % 15% 5;
Switch (f ){
Case 0: Return "#" + CS2 (255-i * 51) + CS2 (I * 51) + "00 ";
Case 1: Return "#00" + CS2 (255-i * 51) + CS2 (I * 51 );
Case 2: Return "#" + CS2 (I * 51) + "00" + CS2 (255-i * 51 );
}
}
Function CS2 (I ){
VaR S = I. tostring (16 );
Return ("00" + S). substr (S. Length );
}

 

You can use GCL to return the gradient color from red to green to blue. Gradient effect:

Http://kingoa.net/WEBPROGRAM/JAVASCRIPT/2010/0326/14021.html

 

Three formats of CSS color values: name, RGB, and hexadecimal

Theoretically, the number of colors that CSS can process is about 16,777,216. Enough. How can we express these colors in three forms:

1. Name: Blue

2. RGB, for example, 255, 0, and 0

3. hexadecimal format: # ff6600

If we want to set the red color, it can be in the following format:

Name: red

RGB: # ff0000

RGB: RGB (100%, 0%, 0%)

Hexadecimal: # ff0000

Hexadecimal: # f00

CSS has 17 predefined colors, which are:

Aqua, black, blue, Fuchsia, gray, green, lime, maroon, navy, Olive, orange, purple, Red, silver, teal, white, yellow.

(Note: transparent transparency is also a correct value .)

The three values of RGB are from 0 to 255, which is the lowest level and is the highest level. These values can also be percentages.

In hexadecimal notation, three or six digits are preceded by # characters, and the three are six compression formats (short hexadecimal). For example, # 00f is # 0000ff compression, # C30 is # cc3300. Three digits are easy to understand, such as RGB. The first is red, the second is green, and the third is blue. However, more color control can be achieved by six digits.

because the Web security color is used only for, 33,, 99, CC, FF, so we can use the short hexadecimal color to indicate the Web Security Color, C, F and the long hexadecimal color values are equivalent, A total of 6x6x6 = 216 types . Only 256 colors can be defined on the first computer (8-bit computer), so windows and Macintosh were running in 256 colors, the colors shared by Netscape Navigator and Microsoft Internet Explorer are called Web Security colors. If the color is not within the range of these 216 colors, the computer may cause jitter when the color is displayed. (Jitter is produced by mixing two colors in order to express a certain color as much as possible.)

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.