I am trying to first remove everything in the ComboBox. And then prepend text to it, but some of the old text remains. Is there a way to RESET or CLEAR the ComboBox? Or how can I best achieve this?
public void GetBadgeName ()
{
try
{
int i = 0;
while (i < 200)
{
cmb_SelectBadge.RemoveText(i);
++i;
}
string connectionString = "URI=file:SIGN.sqlite";
IDbConnection dbcon;
dbcon = (IDbConnection) new SqliteConnection(connectionString);
dbcon.Open();
IDbCommand dbcmd = dbcon.CreateCommand();
string sql =
"SELECT BadgeName " +
"FROM Badge";
dbcmd.CommandText = sql;
IDataReader reader = dbcmd.ExecuteReader();
while(reader.Read()) {
string BadgeName = reader.GetString (0);
cmb_SelectBadge.PrependText(BadgeName);
}
reader.Close();
reader = null;
dbcmd.Dispose();
dbcmd = null;
dbcon.Close();
dbcon = null;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
I figured this out. Simply create a new empty ListStore (I call it ClearList) and then make the combobox.Model equal to the ClearList. Then prepend or append the text as normal to the combobox.