[Gtk-sharp-list] How to remove multiple rows from a TreeStore
?
Dmitry Kostenko
bis0n@mail.ru
Tue, 21 Dec 2004 11:06:12 +0200
Hello, Joris.
Maybe this way?
TreeIter iter;
if (store.GetIterFirst(out iter)) {
do {
bool val = (bool) store.GetValue(iter, 0);
while (val) {
// do something - delete file or whatever
store.Remove(ref iter);
// iter may become invalid, may need to convert to a treepath
val = (bool) store.GetValue(iter, 0);
}
}
while (store.IterNext(ref iter));
}
Joris Willems wrote:
> //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();
> }
> }
>
>
> _______________________________________________
> Gtk-sharp-list maillist - Gtk-sharp-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
>
>
--
Dmitry Kostenko
.NET Developer