Christopher David Howie ha scritto: > On 08/19/2010 01:34 PM, Rampage wrote: > >> i've adapted your snipplet to work in the testcollapse, and it works >> great, it removes all child nodes. >> the problem is that once all children are deleted i can't add anything >> anymore, couse it looks like the iter goes lost, and without the dummy >> value i can't test expansion anymore to trigger the population event. >> > > My understanding (someone correct me if I'm wrong) is that the only iter > that is guaranteed to be valid is the one you're working on when you > mutate the tree. Therefore the original node's iter will be invalid > after the first call to Remove(). > > To work around this, consider inserting your dummy node into the list of > child notes, right at the front. Then call IterNext on that iter to get > the first child to remove, then proceed as normal. So, do something > like this instead: > > TreeIter node = GetIterBeingCollapsed(); > int depth = model.IterDepth(node); > > TreeIter dummy = model.InsertNode(node, 0); > // set values on dummy... > > if (model.IterNext(ref dummy)) { > while (model.IterDepth(dummy) > depth && > model.Remove(ref dummy)); > } > > Wow, wonderfull, it really works like a charm, i still don't understand what out and ref means, i'm really n00b in c# so it was a bit tricky, but now everything seems to work perfectly
Thank you very much for the help. PS: there are so many things i would like to ask you about gtk# i didn't find documentation about.. but i don't want to bug you too much :) _______________________________________________ Gtk-sharp-list maillist - Gtk-sharp-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/gtk-sharp-list