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. Note the value in the combo box was set in a form and saved to a database. Now if I open that form again in pulls up the value previously set in the combo box from the database but it is as if it is not seen by the case statement unless I reselect the value.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");
}
}