[Gtk-sharp-list] Associate user data object with a widget

Chuck Esterbrook chuck.esterbrook at gmail.com
Thu Nov 26 00:21:26 EST 2009


Hi,

I'd like to associate an arbitrary Mono/.NET object with a widget.
Something like:
    button.Data = "foo"
or:
    menuItem.Data = new MyClass();

Looking at the Mono/GTK# docs at http://www.go-mono.com/docs/, I see
there are several data methods at the Gtk.Object level, but they are
marked "deprecated". There is a UserData property, but it returns
IntPtr which the docs even point out is not useful from Mono/.NET.

I grepped the code for some GTK# projects like banshee, f-spot and
MonoDevelop, but their use of UserData seems limited to IntPtr.Zero
and Handle.

As a compromise, if I could at least store an arbitrary int, that
could be an index to a list I keep on the side.

Any help here?

-Chuck


More information about the Gtk-sharp-list mailing list