Ronaldo Nascimento
Ronaldo Nascimento

Reputation: 1571

How to remove all child nodes from parent TreeIter from Gtk.TreeStore?

Given a TreeStore and TreeIter, how do you remove all of the child nodes from a parent WITHOUT deleting the parent? None of these are selected, just want to clear a set of nodes under a parent.

ParentNode
  +- Child 1
  +- Child 2
  +- Child 3

So remove "Child 1-3" and keep ParentNode.

This needs to be looped somehow over something:

        TreePath p = this.game_store.GetPath (this.players_iter);
        p.Down ();
        TreeIter i = new TreeIter ();
        this.game_store.GetIter (out i, p);
        this.game_store.Remove (ref i);

Upvotes: 3

Views: 644

Answers (2)

marbel82
marbel82

Reputation: 948

Try this:

while (this.game_store.Remove (ref i));

Documentation of Remove function says:

"@iter is set to the next valid row at that level," "Return %TRUE if @iter is still valid, %FALSE if not."

Upvotes: 1

Charles Owen
Charles Owen

Reputation: 2910

Try the clear() method.

For your reference:

http://api.gtkd.org/src/gtk/TreeStore.html

Upvotes: 1

Related Questions