Beispiel #1
0
        /**
         * Method to initialize all categories in the combobox in the tab Information and the Tab Post a Question
         */
        public void InitializeCategory()
        {
            List <Category> categoriesKnowledge = new List <Category>();

            categoriesKnowledge = DAOCategory.SelectAllCategories();

            //Clear combobox before add items
            comboBoxCatKnowledge.Items.Clear();

            foreach (Category c in categoriesKnowledge)
            {
                //for each category present in database, add items in combobox
                comboBoxCatKnowledge.Items.Add(c.CategoryName);
            }

            List <Category> categories = new List <Category>();

            categories = DAOCategory.SelectAllCategories();

            //Clear combobox before add items
            comboBoxCategory.Items.Clear();

            //Insert nothing at index 0 because the index can't to begin at index 1
            comboBoxCategory.Items.Insert(0, "");

            foreach (Category c in categories)
            {
                //for each category present in database, add the id of category and the name of categories items in combobox
                comboBoxCategory.Items.Insert(c.CategoryID, c.CategoryName);
            }
        }
Beispiel #2
0
        /*
         * Method is called when the application is loaded
         */
        public void InitializeCategory()
        {
            List <Category> categories = new List <Category>();

            categories = DAOCategory.SelectAllCategories();

            foreach (Category c in categories)
            {
                //Fill the combobox with the name of category
                comboBoxCatKnowledge.Items.Add(c.CategoryName);
            }
        }