Пример #1
0
 private void PopulateComboBox()
 {
     var nhb = new NHibernateBase();
     IList<Guitar> guitarTypes = nhb.ExecuteCriteria<Guitar>();
     foreach (var item in guitarTypes)
     {
         var guitar = new Guitar{ Id = item.Id, Type = item.Type};
         cboBoxGuitarTypes.DisplayMemberPath = "Type";
         cboBoxGuitarTypes.SelectedValuePath = "Id";
         cboBoxGuitarTypes.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);
            }
        }