« Return to Thread: Treeview, delete the selected row (can't get it done :( )

Treeview, delete the selected row (can't get it done :( )

by Werner666 :: Rate this Message:

Reply to Author | View in Thread

Hello,

I have a treeview on my form.
I wan't something very simple but just can't get it done. :(

After clicking 1 button the selected row in my treeview has to be deleted.

This is my code so far:

[code]
TreeIter iter;
TreeModel model;
               
               
TreePath path = ((TreeSelection)sender).GetSelectedRows();
this.klantListStore.GetIter(out iter, path[0]);
Console.WriteLine(path[0]);
                       
klantListStore.Remove(ref iter);
[/code]

But if I compile this and press the delete button I get:

System.InvalidCastException: Cannot cast from source type to destination type.
  at MainWindow.OnButton2Clicked (System.Object sender, System.EventArgs e) [0x00000]

...

Does anybody know what I do wrong?

 « Return to Thread: Treeview, delete the selected row (can't get it done :( )