-
November 14th, 2012, 09:21 AM
#1
first program in c#
I am trying to pick up c# and was wondering if someone could show me what I am doing wrong. In the code below I have three radio buttons(go, slow down, and stop). I also have a checkbox is show the results of what the car is doing when each radio button is checked. When I run the program there is nothing in the textbox and just wanting to see if someone can take a quick look and what is wrong...
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Making_Decisions_Winforms1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
void DoTrafficLight(string color)
{
switch (color)
{
case "green":
textBox1.Text = "The car is moving!";
//tmrYellow.Enabled = true;
break;
case "yellow":
textBox1.Text = "The car is slowing down!";
tmrYellow.Enabled = true;
break;
case "red":
textBox1.Text = "The car has stopped!";
tmrYellow.Enabled = false;
break;
}
}
private void greenRadioButton1_CheckedChanged(object sender, EventArgs e)
{
if (greenRadioButton1.Checked == true)
{
DoTrafficLight("green");
}
}
private void yellowRadioButton1_CheckedChanged(object sender, EventArgs e)
{
if (yellowRadioButton1.Checked == true)
{
DoTrafficLight("yellow");
}
}
private void redRadioButton1_CheckedChanged(object sender, EventArgs e)
{
if (redRadioButton1.Checked == true)
{
DoTrafficLight("red");
}
}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|