[Gtk-sharp-list] TreeModel for storing objects
Eskil Bylund
eskil.bylund at gmail.com
Sat Oct 13 17:43:54 EDT 2007
Hi everyone,
Thanks to Mike it's now possible (using gtk-sharp from svn trunk) to
implement custom TreeModels[1]. Thus I wrote a model that stores
objects and makes the object and a selected set of properties
available as columns in the model.
For example, to show a Person in a tree view, one could simply write:
ObjectStore model = new ObjectStore (typeof(Person), "Firstname", "Lastname");
model.Add(new Person("John", "Lance"));
TreeView view = new TreeView (new TreeModelAdapter (model));
view.AppendColumn ("First", new CellRendererText (), "text", 1); //
The first column is the object
view.AppendColumn ("Last", new CellRendererText (), "text", 2);
sw.Add (view);
Attached is the code and a sample program.
Comments? Ideas?
[1] Any GInterface actually: http://mono-project.com/ImplementingGInterfaces
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ObjectModel.cs
Type: text/x-csharp
Size: 11610 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20071013/ba673d8b/attachment-0001.bin
More information about the Gtk-sharp-list
mailing list