2. Store the color names (red, green, blue, and so forth) in the radio buttons’ Tag properties.
Add code to handle the
RadioButtons’ Click events.
1. Write an event handler similar to the following. The code converts the sender object
into a
RadioButton and uses its Tag property to get the appropriate color. It then
applies that color to the form and the two
GroupBoxes.
// Set the foreground color.
private void Foreground_Click(object sender, EventArgs e)
{
// Get the sender as a RadioButton.
RadioButton rad = sender as RadioButton;
// Use the color.
Color clr = Color.FromName(rad.Tag.ToString());
this.ForeColor = clr;
fgGroupBox.ForeColor = clr;
bgGroupBox.ForeColor = clr;
}
2. Connect the foreground RadioButtons to this event handler.
3. Repeat these steps for the background RadioButtons.
Localize the application for Mexican Spanish.
1. Set the form’s Localizable property to true. Click the Language property, click the
dropdown arrow to the right, and select “Spanish (Mexico).”
2. Change the controls’ Text properties so they have the values shown in Figure 34-6.
Add code to let you test the form for either locale.
1. Use code similar to the following in the form’s constructor:
// Select a locale for testing.
public Form1()
{
// English.
//Thread.CurrentThread.CurrentCulture =
// new CultureInfo(“en-US”, false);
//Thread.CurrentThread.CurrentUICulture =
// new CultureInfo(“en-US”, false);
// Spanish.
Thread.CurrentThread.CurrentCulture =
new CultureInfo(“es-MX”, false);
Thread.CurrentThread.CurrentUICulture =
new CultureInfo(“es-MX”, false);
InitializeComponent();
}
Please select Lesson 34 on the DVD to view the video that accompanies this lesson.
596906c34.indd 393 4/7/10 12:34:47 PM