1
這是我如何填充組合框:重新填充組合框
foreach(string s in entries)
{
string[] fields = someSplit(s);
threadComboBox.AppendText(fields[0]);
}
如何我會刪除所有項目,並添加新的?我嘗試過撥打Clear()
,但是雖然它刪除了舊值,但新值不會被添加。
這是我如何填充組合框:重新填充組合框
foreach(string s in entries)
{
string[] fields = someSplit(s);
threadComboBox.AppendText(fields[0]);
}
如何我會刪除所有項目,並添加新的?我嘗試過撥打Clear()
,但是雖然它刪除了舊值,但新值不會被添加。
嘗試
threadComboBox.Clear();
ListStore store = new ListStore(typeof (string));
threadComboBox.Model = store;
foreach(string s in entries)
{
string[] fields = someSplit(s);
store.AppendValues (fields[0]);
}
接受的答案本身並不爲我工作。我不得不使用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");
什麼是'threadComboBox'?一個簡短但完整的例子會有幫助... – 2011-03-06 19:11:56
一個'ComboBox'包含一些線程(如在bbs中的主題)。 – Gerals 2011-03-06 19:13:08
你在通過你的'foreach'循環之前調用'Clear()'*嗎? – Farray 2011-03-06 19:20:01