如何更改Gtk.TreeModel的值? Gtk.TreeModel.SetValue无效

时间:2009-09-07 00:44:03

标签: c# mono gtk#

这是代码

public void Update(TravTasks.TravellerTask data)
{
    //UNDONE: this algorithm sucks
    TreeIter iter;
    if (this.tasks_tree_store.GetIterFirst(out iter))
    {
        string task_id = this.tasks_tree_store.GetValue(iter, 1).ToString();
        if (task_id.Equals(data.ID.ToString()))
        {
            this.tasks_tree_store.SetValue(iter, 0, data.TaskName);
            this.treeview3.ShowAll();
            return;
        }
        while (this.tasks_tree_store.IterNext(ref iter))
        {
            task_id = this.tasks_tree_store.GetValue(iter, 1).ToString();
            if (task_id.Equals(data.ID.ToString()))
            {
                this.tasks_tree_store.SetValue(iter, 0, data.TaskName);
                return;
            }
        }
    }
}

1 个答案:

答案 0 :(得分:0)

public void Update(TravTasks.TravellerTask data)
{
    TreeSelection tsel = this.treeview3.Selection;
    if (tsel != null)
    {
        TreeIter iter = new TreeIter();
        if (tsel.GetSelected(out iter))
        {
            this.tasks_tree_store.SetValue(iter, 0, data.TaskName);
        }
    }
}