[Gtk-sharp-list] Treeview question (controlling the model using a TreeModel)
Adam Tauno Williams
adam at morrison-ind.com
Wed Jan 2 14:15:22 EST 2008
> it describes how to set up a TreeView so that it is bound to an
> object containing your data. When the data in your object changes, so
> does the TreeView thus allowing you to update the data easily.
> My problem is that the example uses a ListModel rather than a
> TreeModel as in the previous section
> (http://www.mono-project.com/GtkSharp_TreeView_Tutorial#Your_first_TreeView).
> If anyone has any examples of how to do this above using a TreeModel I
> would greatly appreciate it.
I guess I don't understand the question. Where did you get "ListModel"
from? It isn't anywhere in the provided examples, you attach a
ListStore to a TreeModel, and just have a TreeView with only one
'level'.
Gtk.TreeView tree = new Gtk.TreeView ();
Gtk.ListStore musicListStore = new Gtk.ListStore (typeof (string), typeof (string));
...
tree.AppendColumn ("Artist", new Gtk.CellRendererText (), "text", 0);
tree.AppendColumn ("Title", new Gtk.CellRendererText (), "text", 1);
musicListStore.AppendValues ("Garbage", "Dog New Tricks");
tree.Model = musicListStore; <-- Model is the the ListStore
ListStore & TreeStore should be able to be used pretty much
interchangeably AFAIK, depending on the need of the application
Admittedly, TreeView is an intimidating beast.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 194 bytes
Desc: This is a digitally signed message part
Url : http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20080102/72d14262/attachment.bin
More information about the Gtk-sharp-list
mailing list