Hi,
Get the values like this instead:
int x = (int)m.GetValue (a, 3);
int y = (int)m.GetValue (b, 3);
and I think it will work better for you!
/Fredrik
Callum J. Bell wrote:
I'm posting to this group because the origin of the problem is sorting
columns in a ListStore that is a model for a TreeView. I want to sort
a column of integers so I started writing a sortfunction:
public int int_compare(TreeModel m, TreeIter a, TreeIter b)
{
GLib.Value x = new GLib.Value();
GLib.Value y = new GLib.Value();
m.GetValue(a,3,ref x);
m.GetValue(b,3,ref y);
// At runtime the next two lines throw: Unhandled Exception:
//System.InvalidCastException: Cannot cast from source type to
//destination type.
int i = (int)(x.Val);
int j = (int)(y.Val);
// But x.Val does contain an integer that gets unboxed correctly
// here:
System.Console.WriteLine(">> " + x.Val + " <<");
// Never got this far...
//return i.CompareTo(j);
// This is for debugging
return 1;
}
It looks to me as if the cast should work. Any ideas? Also, if there
are sortfunctions out there for various types I'd appreciate a pointer
to them.
Thanks
Callum
_______________________________________________
Gtk-sharp-list maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
_______________________________________________
Gtk-sharp-list maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list