Werner666 wrote:
[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]
The Exception is in the OnButton2Clicked Method.
Is the code you posted above inside this OnButton2Clicked Method?
If yes, sender is the button you clicked on. So you tried to cast a button to a TreeSelection. That's why you get a InvalidCastException.