Assign a value to combobox depend upon other combobox value I have a windows form in C# project that keeps some information. I created a bunch of textbox and combobox dynamically, depend upon user input.

Consider, I have a list of 10 combobox whose values will be selected by user.

The combobox values are:


Finding
No Finding
Incomplete
Skipped.


Now I have a single final combobox  which contains the following values.


Finding
No Finding
Incomplete
Skipped Reviewed
Skipped Not reviewed


The final combobox  should be populated depend upon the following logic


If all values are "Finding",  then the the final combobox should be "Finding"
If all values are "No_Finding", then the the final combobox should be "No_Finding"
If all values are "InComplete", then the the final combobox should be "InComplete"
If all values are "Skipped", then the the final combobox should be "Skipped Not Reviewed".
If any value is "Finding", then the final combobox should be "Finding".
If any value is "Incomplete", then the final combobox should be "Incomplete".
If any value is "Skipped", then the final combobox should be "Skipped Reviewed".


With respect to the above logic conditions I have written the following that works fine. 

After writing the code I feel it's not cleaner and not an easily understandable solution.

What I need now whether there is any way to refactor the following lines of code. 

 public void selectfinalComboxValue()
        {
            List&lt;string&gt; list_of_combobox = new List&lt;string&gt;();
//txtBoxValLines is an user input 
            for (int i = 0; i &lt; int.Parse(txtboxvalLines.Text); i++)
            {
                string cmbboxValue = ((ComboBox)panel1.Controls["Add_combobox" + (i).ToString()]).Text;
                list_of_combobox.Add(cmbboxValue);

            }
            List&lt;string&gt; distinct = list_of_combobox.Distinct().ToList();

            if (distinct.Any(str =&gt; str.Contains("InComplete")))
            {
                cmbFinalStatus.SelectedIndex = 2;
                cmbFinalStatus.Enabled = false;
            }
            else if (distinct.Any(str =&gt; str.Equals("Finding")))
            {
                cmbFinalStatus.SelectedIndex = 0;
                cmbFinalStatus.Enabled = false;
            }
            else
            {
                cmbFinalStatus.SelectedIndex = -1;
                cmbFinalStatus.Enabled = true;
            }

            if (distinct.Count().ToString() == "1")
            {

                if (distinct.Any(str =&gt; str.Equals("Skipped")))
                {
                    cmbFinalStatus.SelectedIndex = 4;
                    cmbFinalStatus.Enabled = false;
                }
                else if (distinct.Any(str =&gt; str.Equals("No Finding")))
                {
                    cmbFinalStatus.SelectedIndex = 1;
                    cmbFinalStatus.Enabled = false;
                }
            }
            else {
                if (distinct.Any(str =&gt; str.Contains("Skipped")))
                {
                    cmbFinalStatus.SelectedIndex = 3;
                    cmbFinalStatus.Enabled = false;
                }

            }            
        }
I think you might be able to eliminate creating the distinct list and the nested ifs by first checking for the All() condtions, then later check for Any()

    var items = list_of_combobox.ToList();

    if (items.All(str =&gt; str.Equals("Finding")))
    {
       // assign final comboxbox 
    }
    else  if (items.Any(str =&gt; str.Equals("Finding")))


Also, you might want to try creating an enum of the possible values, adding these values to the ComboBox, then getting/setting the SelectedItem property rather than dealing with indexes.