Help I need a quicker way to do this, its a combobox that assigns a number to whatevers selected and it takes up to much room and looks messy.

private void comboBox19_SelectedIndexChanged(object sender, EventArgs e)
        {
           
                if (comboBox19.Items[comboBox19.SelectedIndex].ToString() == "Clear Float")
                {
                    glassType10 = 200;
                }

                else if (comboBox19.Items[comboBox19.SelectedIndex].ToString() == "Low E")
                {
                    glassType10 = 250;
                }

                else if (comboBox19.Items[comboBox19.SelectedIndex].ToString() == "Toughened Low E")
                {
                    glassType10 = 480;
                }

                else if (comboBox19.Items[comboBox19.SelectedIndex].ToString() == "Toughened Float One Side")
                {
                    glassType10 = 350;
                }

                else if (comboBox19.Items[comboBox19.SelectedIndex].ToString() == "Clear Laminate Low E")
                {
                    glassType10 = 400;
                }

                else if (comboBox19.Items[comboBox19.SelectedIndex].ToString() == "Float Gray Tint")
                {
                    glassType10 = 300;
                }

                else if (comboBox19.Items[comboBox19.SelectedIndex].ToString() == "Flaot Gray Tint Toughened One Side")
                {
                    glassType10 = 260;
                }

                else if (comboBox19.Items[comboBox19.SelectedIndex].ToString() == "Obscure - Toilet Only")
                {
                    glassType10 = 180;
                }

                else if (comboBox19.Items[comboBox19.SelectedIndex].ToString() == "Float Gray Tint Toughened One Side")
                {
                    glassType10 = 280;
                }

                else if (comboBox19.Items[comboBox19.SelectedIndex].ToString() == "Toughened E Tch Lite - Toilet Only")
                {
                    glassType10 = 320;
                }

                else if (comboBox19.Items[comboBox19.SelectedIndex].ToString() == "E Tch Lite - Toughened One Side")
                {
                    glassType10 = 450;
                }
        }

oops.. might wanna edit your post (if you can?) and add the closing
[/code] statement

To make it not so messy you could define a string like this :
string selection = comboBox19.Items[comboBox19.SelectedIndex].ToString() ; and change your if-statement in :

if (selection == "Clear Float")
    glassType10 = 200;
else if ( selection == "Low E")
    glassType10 = 250;
//......

Yes, you may omit the curly braces here, because you only have one statement after every if.

Thank you that works great!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.