I have four combo boxes where I want an image to change (along with another two lines of code) when they are changed on selection. The one for Desks (comDesks) works. That's the one I did first. Then I cut and pasted the rest. As far as I can see I changed everything correctly for the other three. When I run the program and change the combo box for chairs, comps, or stations the picture does not change. I used imageLists for each one with a swich statement. REMEMBER that the desks works, it's the first one I wrote EVEN THOUGH it's the second section of code after chairs. (ADDED May 4th: I cut and pasted the switch statement, I did not cut and paste the event. The event is linked properly as far as I can tell.) Here is my code:
private void comChairs_SelectedIndexChanged(object sender, EventArgs e)
{
// switch statement for selection change
switch (comChairs.SelectedIndex)
{
case 0:
// Change image
pbxChairs.Image = imgChairs.Images[0];
// Set price to variable used later
chairCost = 90.00m;
// Set description to variable used later
chairString = comChairs.SelectedItem.ToString();
break;
case 1:
pbxChairs.Image = imgChairs.Images[1];
chairCost = 135.00m;
chairString = comChairs.SelectedItem.ToString();
break;
case 2:
pbxChairs.Image = imgChairs.Images[2];
chairCost = 220.00m;
chairString = comChairs.SelectedItem.ToString();
break;
default:
break;
}
}
private void comDesks_SelectedIndexChanged(object sender, EventArgs e)
{
switch (comDesks.SelectedIndex)
{
case 0:
pbxDesks.Image = imgDesks.Images[0];
deskCost = 450.00m;
deskString = comDesks.SelectedItem.ToString();
break;
case 1:
pbxDesks.Image = imgDesks.Images[1];
deskCost = 650.00m;
deskString = comDesks.SelectedItem.ToString();
break;
case 2:
pbxDesks.Image = imgDesks.Images[2];
deskCost = 1000.00m;
deskString = comDesks.SelectedItem.ToString();
break;
default:
break;
}
}
private void comComps_SelectedIndexChanged(object sender, EventArgs e)
{
switch (comComps.SelectedIndex)
{
case 0:
pbxComps.Image = imgComps.Images[0];
compCost = 849.00m;
compString = comComps.SelectedItem.ToString();
break;
case 1:
pbxComps.Image = imgComps.Images[1];
compCost = 1250.00m;
compString = comComps.SelectedItem.ToString();
break;
case 2:
pbxComps.Image = imgComps.Images[2];
compCost = 1799.00m;
compString = comComps.SelectedItem.ToString();
break;
default:
break;
}
}
private void comStations_SelectedIndexChanged(object sender, EventArgs e)
{
switch (comStations.SelectedIndex)
{
case 0:
pbxStations.Image = imgStations.Images[0];
stationCost = 1250.00m;
stationString = comStations.SelectedItem.ToString();
break;
case 1:
pbxStations.Image = imgStations.Images[1];
stationCost = 1450.00m;
stationString = comStations.SelectedItem.ToString();
break;
case 2:
pbxStations.Image = imgStations.Images[2];
stationCost = 2500.00m;
stationString = comStations.SelectedItem.ToString();
break;
default:
break;
}
}