[Gtk-sharp-list] GTk# dynamic treeview population
atomikramp at email.it
Tue Aug 10 13:39:59 EDT 2010
Michael Hutchinson ha scritto:
> On Mon, Aug 9, 2010 at 7:58 PM, Rampage <atomikramp at email.it> wrote:
>> Hello everyone, i have a question about populating treeviews.
>> i was following this tutorial:
>> and there is a part of the article that explains how to populate a tree.
>> The problem is that as it's explained in that tutorial, it looks like i have
>> to define the tree structure immediatelly before rendering it.
>> i was wondering: is there a way to populate the tree dynamically?
>> what i mean is:
>> try to expand a node
>> an event is triggered and a method is called
>> the method returns me a list of eventually available children
>> if the returned value is not null, append the values to the parent
>> else if the returned value is null: that node doesn't have children
> Yes, there is an event on the TreeView:
> In an eventhandler for that event, you can inspect the treestore and
> add any rows needed.
I've tried playing around with that event and when i click on the + near
a node it triggers the event.
but my scenario is pretty different, here i explain.
i have a method that forks a process.
This method returns me with an array of structures that is like
at this point everything seems ok, since if i create a root node i can
append some values to it from that array of structure.
Gtk.TreeIter iter = dirtreestore.AppendValues("test");
for(int i = 0; i < prova.Length; i++)
i cut a part of code but also the id is added into an hidden column so
that i can use it for my purposes.
now comes the hard part (for me)
couse if i pass the id to the process i've forked before, it returns me
with another array of structures similar to first one, and this values
are children of the node with that id.
it's pretty complex with my bad english for me to explain it in detail
but let's say that i would like to:
if i click on the + near an element of the treeview
the id value of that element (wich is in the hidden column) is passed to
my method to return me a new list of items that i want to append to the
node i've tried to expand.
but till i run the command i don't know if i'll have any output to append.
hope i was clear enaugh.
Thanks for the help.
More information about the Gtk-sharp-list