This is how I populate the combo box:
foreach(string s in entries)
{
string[] fields = someSplit(s);
threadComboBox.AppendText(fields[0]);
}
How would I remove all items and add new ones? I tried calling Clear()
, but while it does remove old values, new ones don't get added.
try
threadComboBox.Clear();
ListStore store = new ListStore(typeof (string));
threadComboBox.Model = store;
foreach(string s in entries)
{
string[] fields = someSplit(s);
store.AppendValues (fields[0]);
}
The accepted answer did not work for me by itself. I had to use the snippet from the FAQ:
cb.Clear();
CellRendererText cell = new CellRendererText();
cb.PackStart(cell, false);
cb.AddAttribute(cell, "text", 0);
ListStore store = new ListStore(typeof (string));
cb.Model = store;
//now this works:
cb.AppendText("test");