重新填充组合框 [英] Repopulate a combo box

查看:139
本文介绍了重新填充组合框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我如何填充组合框:

  foreach(条目中的字符串s)
{
string [] fields = someSplit(s);
threadComboBox.AppendText(fields [0]);
}

如何删除所有项目并添加新项目?我尝试调用 Clear(),但是当它删除旧值时,新的值不会被添加。

解决方案

try

  threadComboBox.Clear(); 
ListStore store = new ListStore(typeof(string));
threadComboBox.Model = store;

foreach(条目中的字符串s)
{
string [] fields = someSplit(s);
store.AppendValues(fields [0]);
}


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]);          
    }

这篇关于重新填充组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆