I have a DataTable with Item information, and a form to order Items. On the Order form there is a ComboBox displaying the Item Names:
void fillComboItem()
{
string constring = @"Data Source=|DataDirectory|\LWADataBase.sdf";
string Query = "select * from stockTBL; ";
SqlCeConnection conDataBase = new SqlCeConnection(constring);
SqlCeCommand cmdDataBase = new SqlCeCommand(Query, conDataBase);
SqlCeDataReader myReader;
try
{
conDataBase.Open();
myReader = cmdDataBase.ExecuteReader();
while (myReader.Read())
{
string sName = myReader.GetString(myReader.GetOrdinal("Item Name"));
comboItem.Items.Add(sName);
}
//displays a system error message if a problem is found
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
When I insert data into the DataTable, it does not update the ComboBox in the Order form and I have to restart the application for it to update. How can I "refresh" the ComboBox?