On Sat, Feb 27, 2010 at 7:26 AM, a B <[email protected]> wrote:
> Hello,
> 1) I'm trying to check if a specific string exists in a TreeStore (which
> contains strings). I tried using the Foreach method but I cannot send the
> string to the TreeModelForeachFunc which I created. What should I do?

Use the TreeIter to get the value from the TreeModel, i.e.

store.Foreach (delegate (TreeModel model, TreePath path, TreeIter iter) {
    var col0Value = (string) model.GetValue (iter, 0);
});

You can also walk the store directly:

TreeIter iter;
if (store.GetIterFirst (out iter)) {
    do {
        var col0Value = (string) store.GetValue (iter, 0);
    } while (store.IterNext (ref iter));
}

> 2) I want the cells in a specific column to be editable using a
> CellRendererCombo. How do I do it?

IIRC you must set Editable to true, and handle the Edited event, from
which you should update the store. Something like the following:

cellRenderer.Editable = true;
cellRenderer.Edited += delegate(object o, EditedArgs args) {
    TreeIter iter;
    if (store.GetIter (args.Path, out iter)) {
        store.SetValue (iter, 0, args.NewText);
        return true;
    }
    return false;
};


-- 
Michael Hutchinson
http://mjhutchinson.com
_______________________________________________
Gtk-sharp-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list

Reply via email to