private void PopulateComboBox()
 {
     var nhb = new NHibernateBase();
     IList<Guitar> GuitarTypes = nhb.ExecuteICriteria<Guitar>();
     foreach (Guitar item in GuitarTypes)
     {
         var guitar = new Guitar(item.Id, item.Type);
         comboBoxGuitarTypes.DisplayMemberPath = "Type";
         comboBoxGuitarTypes.SelectedValuePath = "Id";
         comboBoxGuitarTypes.Items.Add(guitar);
     }
 }
示例#2
0
        private void PopulateComboBox()
        {
            NHibernateBase nhb = new NHibernateBase();

            // get all the guitar types from the DB.
            IList<Guitar> guitarTypes = nhb.ExecuteICriteria<Guitar>();

            // clear all items from the combo box.
            this.guitarTypesComboBox.Items.Clear();

            // add them to the combo box.
            foreach (var item in guitarTypes)
            {
                Guitar guitar = new Guitar {Id = item.Id, Type = item.Type};
                guitarTypesComboBox.DisplayMemberPath = "Type";
                guitarTypesComboBox.SelectedValuePath = "Id";
                guitarTypesComboBox.Items.Add(guitar);
            }
        }