Export (0) Print
Expand All
Expand Minimize

Color::G Property

Gets the green component value of this Color structure.

Namespace:  System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)

property unsigned char G {
	unsigned char get ();

Property Value

Type: System::Byte
The green component value of this Color.

The color of each pixel is represented as a 32-bit number: 8 bits each for alpha, red, green, and blue (ARGB). Each of the four components is a number from 0 through 255, with 0 representing no intensity and 255 representing full intensity. Likewise, G is a value from 0 to 255 with 0 representing no green and 255 representing fully green.

The following code example demonstrates the A, R, G, and B properties of a Color, and the Implicit member.

This example is designed to be used with a Windows Form. Paste the code into the form and call the ShowPropertiesOfSlateBlue method from the form's Paint event-handling method, passing e as PaintEventArgs.

void ShowPropertiesOfSlateBlue( PaintEventArgs^ e )
   Color slateBlue = Color::FromName( "SlateBlue" );
   Byte g = slateBlue.G;
   Byte b = slateBlue.B;
   Byte r = slateBlue.R;
   Byte a = slateBlue.A;
   array<Object^>^temp0 = {a,r,g,b};
   String^ text = String::Format( "Slate Blue has these ARGB values: Alpha:{0}, " 
   "red:{1}, green: {2}, blue {3}", temp0 );
   e->Graphics->DrawString( text, gcnew System::Drawing::Font( this->Font,FontStyle::Italic ), gcnew SolidBrush( slateBlue ), RectangleF(PointF(0.0F,0.0F),this->Size) );

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0
© 2015 Microsoft