[Gtk-sharp-list] Treeview holding tree of objects (with embedded
collection inside)
Jon García de Salazar Bilbao
j.garcia at ziv.es
Mon Jun 19 14:01:58 EDT 2006
Hi,
I'm trying to figure out how to use best my treeview to represent my
app data. I want the TreeStore to hold objects (not strings) in order to
make my front end more simple. The objects I hold contain collections
of other objects that I'd like to visualize too, thus I could access the
different methods provided by every object (objects and subojects) selected
in the treeview pretty easily.
[-] Object1
Subobject1
Subobject2
[+] Object2
[-] Object3
Subobject1
...
I decided to do it like this:
store = new TreeStore(typeof(IObject));
foreach (IObject object in ...)
{
store.AppendValues(object);
}
column.SetCellDataFunc(device_cell, new TreeCellDataFunc(RenderObject));
But I do not know how to render Subobjects in the tree? Should I try
something like this?
class Object : IItem {...}
class Suboject : IItem {...}
tore = new TreeStore(typeof(IItem));
foreach(IItem object in ...)
{
TreeIter iter = store.AppendValues(object);
foreach (IItem suboject in object...)
{
store.AppendValues(iter, subobject);
}
}
column.SetCellDataFunc(device_cell, new TreeCellDataFunc(RenderItem));
Is there a right way to get my tree to manage those kinds of objects easily?
Thanks in advance, Jon.
More information about the Gtk-sharp-list
mailing list