I have some code that checks a value in a combo box before it executes but it does not appear to be seeing the value selected in the combo box until I select the item in the combo box for a second time. Im using a case statement when determining what to do based on the values in the combo box.
My code looks like this:
private void optypCB_Click(object sender, EventArgs e)
{
switch (optypCB.Text)
{
case "Draw":
wearTB.Text = "4";
pinsTB.Text = "0";
nitrogenLowerCheckBox.Checked = true;
densityTB.Text = Convert.ToString(.35); break;
case "Trim":
wearTB.Text = Convert.ToString(4);
pinsTB.Text = Convert.ToString(4);
densityTB.Text = Convert.ToString(.35); break;
case "Form":
wearTB.Text = Convert.ToString(4);
pinsTB.Text = Convert.ToString(4);
densityTB.Text = Convert.ToString(.35); break;
case "Pierce":
wearTB.Text = Convert.ToString(4);
pinsTB.Text = Convert.ToString(4);
densityTB.Text = Convert.ToString(.35); break;
case "Blank":
wearTB.Text = Convert.ToString(4);
pinsTB.Text = Convert.ToString(4);
densityTB.Text = Convert.ToString(.45); break;
default:
throw new Exception("Unknown selection");
}
}
My code looks like this:
private void optypCB_Click(object sender, EventArgs e)
{
switch (optypCB.Text)
{
case "Draw":
wearTB.Text = "4";
pinsTB.Text = "0";
nitrogenLowerCheckBox.Checked = true;
densityTB.Text = Convert.ToString(.35); break;
case "Trim":
wearTB.Text = Convert.ToString(4);
pinsTB.Text = Convert.ToString(4);
densityTB.Text = Convert.ToString(.35); break;
case "Form":
wearTB.Text = Convert.ToString(4);
pinsTB.Text = Convert.ToString(4);
densityTB.Text = Convert.ToString(.35); break;
case "Pierce":
wearTB.Text = Convert.ToString(4);
pinsTB.Text = Convert.ToString(4);
densityTB.Text = Convert.ToString(.35); break;
case "Blank":
wearTB.Text = Convert.ToString(4);
pinsTB.Text = Convert.ToString(4);
densityTB.Text = Convert.ToString(.45); break;
default:
throw new Exception("Unknown selection");
}
}