[Gtk-sharp-list] How to remove multiple rows from a TreeStore ?

Joris Willems trendzetter@pandora.be
Mon, 20 Dec 2004 23:58:07 +0100


       //Delete some rows from a TreeStore
       private void on_cmdDelete_clicked (object o, EventArgs args)
       {
            
            TreeIter iter = new TreeIter ();
            store.GetIterFirst (out iter);
            while (store.IterNext(ref iter))
            {
            
                //Check if the Togglebox is checked
                bool val = (bool) store.GetValue(iter, 0);
                
                //if the Togglebox is checked remove the row
                if (val==true)
                    {
                    vDS.DeleteFile((int)store.GetValue(iter,1));
                    store.Remove(ref iter);
                    }
            }
               
       }

This works but i need to click several times and I cannot remove the 
first row.

I found something in Java that should do what I need but I couldn't port 
it to c#.

 public void removeButtonClicked() {
 	TreePath path = new TreePath("0");
 	//stop at the end of the list
 	while (store.getIter(path) != null) { 
 		//remove contiguous selected rows
 		while (mySelection.getSelected(path))
 			store.removeRow(store.getIter(path));
 		//step ahead until an unselected row or null is found
 	   	while (!mySelection.getSelected(path) && store.getIter(path) != null)  
 			path.next();
 		}
 	}