Ok, thanks.
And this code is in the button2clicked event indeed.
I decided to do is this way:
.. onSelectionChangedEvent ...
((TreeSelection)o).GetSelected(out iterSelected);
//iterSelected is an public var inside the class, not declared inside a method. :) And its a TreeIter yes. ;)
Than in button2Clicked
listStore.Remove(ref iterSelected);
Well... my application doesn't crash anymore. :D
But now I get this error when clicking the delete button:
(CustomerAdministartor:3579): Gtk-CRITICAL **: gtk_tree_store_remove: assertion `VALID_ITER (iter, tree_store)' failed
I don't really understand what this means... :( Except the part that he failed to delete the row I selected. :P
countcb wrote:
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.