In: Computer Science
Write a Visual C# project that will allow the user an option to
choose from four different countries. When a country is chosen, the
program will display the country flag and information that the user
wishes to see. The name of the country selected will be displayed
in a label under the country's flag image. The user may also choose
to display or hide the form's title, the country name, and the name
of the programmer/developer. Check boxes will be used
for the display/hide choices. Radio buttons will be used for the
country selection.
You may choose the countries to display and their corresponding
flags to display. In the Canvas module, you will see a zip file of
flag images or you may choose your own.
Note: see the Note from the previous projects.
These are now considered Basic Expectations and are expected in
each program you develop and submit for grading.
Additionally, include keyboard access keys for all option buttons,
check boxes, and command buttons. (add to Basic Expectations)
Be sure the tab order is set in the most logical order for the
user. (add to Basic Expectations)
Dear Student ,
As per the requirement submitted above , kindly find the below solution.
Here a new Windows Forms Application in C# is created using Visual Studio 2017 with name "CountryApplication".This application contains a form with name "Form1.cs".Below are the files associated with form1.
Form1.cs
//namespace
using System;
using System.Windows.Forms;
//application namespace
namespace CountryApplication
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//When Indian Flag radio button checked , display indian flag and
information
private void rbtIndia_CheckedChanged(object sender, EventArgs
e)
{
pbCountryFlag.Image
=System.Drawing.Image.FromFile(Application.StartupPath
+"\\Flags\\India.jpg");//set flag
lblName.Text="India";//set country name
}
//When Australia Flag radio button checked , display Australia flag
and information
private void rbtAustralia_CheckedChanged(object sender, EventArgs
e)
{
pbCountryFlag.Image =
System.Drawing.Image.FromFile(Application.StartupPath +
"\\Flags\\Australia.jpg");//set flag
lblName.Text = "Australia";//set country name
}
//When Japan Flag radio button checked , display Japan flag and
information
private void rbtJapan_CheckedChanged(object sender, EventArgs
e)
{
pbCountryFlag.Image =
System.Drawing.Image.FromFile(Application.StartupPath +
"\\Flags\\Japan.jpg");//set flag
lblName.Text = "Japan";//set country name
}
//When Germany Flag radio button checked , display Germany flag and
information
private void rbtGermany_CheckedChanged(object sender, EventArgs
e)
{
pbCountryFlag.Image =
System.Drawing.Image.FromFile(Application.StartupPath +
"\\Flags\\german.jpg");//set flag
lblName.Text = "Germany";//set country name
}
//checkbox to hide and display choices
private void chkChoices_CheckedChanged(object sender, EventArgs
e)
{
if(chkChoices.Checked==true)
{
this.Text = "";//do not display title
lblName.Visible = false;//hide the country name
lblProgrammer.Visible = false;//hide pogrammer name
}
else
{
this.Text = "Country Selection";// display title
lblName.Visible = true;//show the country name
lblProgrammer.Visible = true;//show pogrammer name
}
}
}
}
======================================================
Output : Run application using F5 and will get the screen as shown below
Screen 1 :
Screen 2:Screen when choices are hidden
NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.