combobox refresh

larryse

Member
Joined
Dec 25, 2012
Messages
6
Programming Experience
1-3
I have a combo box populated with a list of objects. Selecting an item in the box fills text fields with info where I can do my CRUDS functions of it. My code works except trying to refresh my combo after the CRUD. Here is my code.
       private void Author_Load(object sender, EventArgs e)
        {
            am = AuthorManager.Instance;
            populateList();
       }


        private void populateList()
        {
            uxCboAuthors.DataSource = am.getAll();
            Console.WriteLine("populate list");
            uxCboAuthors.DisplayMember = "FullName";
            uxCboAuthors.ValueMember = "Id";
            uxCboAuthors.SelectedIndex = 0;
            uxCboAuthors.Refresh();
        }

        private void uxCmdDelete_Click(object sender, EventArgs e)
        {
            a = (AuthorDomain)uxCboAuthors.SelectedItem;
            int result = 0;


            result = am.Delete(a);


            populateList();
            clearFields();
        }


am is a reference to my author manager class which contains my sql delete code. if i close and open my form it does remove my person, but i want my combo to update automatic with my populatelist method, which it is not doing.
 
Last edited by a moderator:
Instead of binding your list directly to the ComboBox, bind it to a BindingSource and bind that to the ComboBox. You can then call ResetBindings on the BindingSource.
 
Back
Top Bottom