Ajit N

Ajit N

  • 1.3k
  • 352
  • 68.2k

How To Refresh ComboBox ?

Jan 19 2017 1:58 AM
Hi, I want to refresh the combobox. when i update data in child form, the combobox will be update in parent form. i tried following code it will update, but in combobox it also displayed the previous data.
 
so help me how can i refresh combobox ?
 
This is my code....
  1. private void StudentRegistration_Load(object sender, EventArgs e)  
  2.         {  
  3.             cmbclass.Items.Clear();  
  4.             FillClass();  
  5.         }  
  6.   
  7. public void FillClass()  
  8.         {  
  9.             SqlCommand cmdfill = new SqlCommand("select Class from AddClass", con);  
  10.             SqlDataReader drfill = cmdfill.ExecuteReader();  
  11.             while (drfill.Read())  
  12.             {  
  13.   
  14.                 cmbclass.Items.Add(drfill[0]);  
  15.             }  
  16.   
  17.         } 
 

Answers (4)