コード例 #1
0
        private void getListGroups()
        {
            Dictionary <int, string> comboSource1 = new Dictionary <int, string>();

            try
            {
                UniStructure        group = new UniStructure();
                int                 key   = ((KeyValuePair <int, string>)comboBox1.SelectedItem).Key;
                List <UniStructure> sp    = group.groupsData(key);


                for (int y = 0; y < sp.Count; y++)
                {
                    comboSource1.Add(sp[y].id_group, sp[y].name_group);
                }
            }catch
            {
                comboSource1.Add(-1, "Пусто");
            }
            finally
            {
                comboBox2.DataSource    = new BindingSource(comboSource1, null);
                comboBox2.DisplayMember = "Value";
                comboBox2.ValueMember   = "Key";
            }
        }
コード例 #2
0
        private void getListSpecialties()
        {
            Dictionary <int, string> comboSource = new Dictionary <int, string>();

            try
            {
                UniStructure        spec = new UniStructure();
                List <UniStructure> sp   = spec.specialitiesData();


                for (int y = 0; y < sp.Count; y++)
                {
                    comboSource.Add(sp[y].id_spec, sp[y].name_spec);
                }
            }catch {
                comboSource.Add(-1, "Пусто");
            }finally
            {
                comboBox1.DataSource    = new BindingSource(comboSource, null);
                comboBox1.DisplayMember = "Value";
                comboBox1.ValueMember   = "Key";
            }
        }