Difference between revisions of "Setting up Combo Boxes in C Sharp"

From PeformIQ Upgrade
Jump to navigation Jump to search
(Created page with "=C# Combo Boxes= <pre> Year = DateTime.Now.Year; var Combo_Years = new BindingList<KeyValuePair<int, string>>(); IEnumerable<int> years...")
 
 
Line 18: Line 18:


             Combo_Year.SelectedText = Year.ToString();
             Combo_Year.SelectedText = Year.ToString();
            Cursor.Current = Cursors.WaitCursor;
           
            var testnums = AnnotationSet.GetTests(Year);
            Cursor.Current = Cursors.Default;
</pre>
</pre>


[[Category:CSharp]]
[[Category:CSharp]]
[[Category:Development]]
[[Category:Development]]

Latest revision as of 12:29, 11 March 2019

C# Combo Boxes

            Year = DateTime.Now.Year;

            var Combo_Years = new BindingList<KeyValuePair<int, string>>();

            IEnumerable<int> years = Enumerable.Range(2017, Year);

            foreach (int year in years)
            {
                Combo_Years.Add(new KeyValuePair<int, string>(year, year.ToString()));
            }

            Combo_Year.DataSource = Combo_Years;
            Combo_Year.ValueMember = "Key";
            Combo_Year.DisplayMember = "Value";

            Combo_Year.SelectedText = Year.ToString();