ASDV-C-Sharp/Lab4_2/Lab4_6_CalebFontenot/Form1.cs

52 lines
1.5 KiB
C#
Raw Normal View History

2022-09-13 15:08:17 -05:00
namespace Lab4_6_CalebFontenot
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void okButton_Click(object sender, EventArgs e)
{
string city; // To hold the name of a city
if (cityListBox.SelectedIndex != -1)
{
// Get the selected list item
city = cityListBox.SelectedItem.ToString();
// Determine the time zone.
switch (city)
{
case "Honolulu":
timeZoneLabel.Text = "Hawaii-Aleutian";
break;
case "San Francisco":
timeZoneLabel.Text = "Pacific";
break;
case "Denver":
timeZoneLabel.Text = "Mountain";
break;
case "Minneapolis":
timeZoneLabel.Text = "Central";
break;
case "New York":
timeZoneLabel.Text = "Eastern";
break;
}
}
else
{
// No city was selected.
MessageBox.Show("Select a city.");
}
}
private void exitButton_Click(object sender, EventArgs e)
{
// Close the form.
this.Close();
}
}
}