If you have ever created web pages using HTML, you are probably familiar with
that language's various tags and you may know that a tag can contain attributes.
An example of a tag would be <body> and inside of the tag, you can create
the attributes you want.

This application shows an example of visually creating the attributes of the
HTML's body tag, mainly the colors.

When the user clicks a radio button from the Body Attributes group box,
we need to display its color on the Preview panel. When a particular button
is clicked, we will
retrieve the color of its font from the Body text box, translate that color
into red, green, and blue values, and then use those values to automatically
update the scroll bars and the edit boxes. While we are at it, we also need
to update the corresponding text box in the Body Attributes group box. Since
this functionality will be used by all radio buttons in the group, we will
use a global function to which we can pass two variables.
When the user clicks a particular radio button, that button is represented
by a text box in the lower-left Body section. We need to get the color of
that edit box and pass it to our function. Since the clicked radio button
has a corresponding text box in the Body Attributes group box, we need to
change/update that value with the hexadecimal value of the first argument.
Therefore, we will pass a string argument to our function.
In the Code Editor, just after the closing curly bracket of the scrBlue_Scroll
event, create the following method:

internal void ClickOption(System.Drawing.Color Clr, String Result)
{
// These variables will hold the red, green, and blue
// values of the passed color
int red, green, blue;
// Colorize the Preview panel with the passed color
pnlPreview.BackColor = Clr;
// Get the red value of the color of the Preview panel
red = 255 - pnlPreview.BackColor.R;
// Get the green value of the color of the Preview panel
green = 255 - pnlPreview.BackColor.G;
// Get the blue value of the color of the Preview panel
blue = 255 - pnlPreview.BackColor.B;
// Now that we have the red, green, and blue values of the color,
// Update the scroll bars with the new values
scrRed.Value = red;
scrGreen.Value = green;
scrBlue.Value = blue;
// Update the red, green, and blue values
// of the Numeric Values group box
txtRed.Text = red.ToString();
txtGreen.Text = green.ToString();
txtBlue.Text = blue.ToString();
// Update the string that was passed using
// the retrieved red, green, and blue values
Result = String.Concat(Result, "#");
Result = String.Concat(Result, red.ToString("X"));
Result = String.Concat(Result, green.ToString("X"));
Result = String.Concat(Result, blue.ToString("X"));
}

Return to the form

Double-click the Background radio button and implement its event as follows: