[Gtk-sharp-list] Dynamically populating a TreeStore

Chris Ridd chris.ridd@isode.com
Tue, 17 Aug 2004 12:38:38 +0100

On 17/8/04 2:05 am, Jonathan Pryor <jonpryor@vt.edu> wrote:

> On Mon, 2004-08-16 at 13:38, Chris Ridd wrote:
> <snip/>
>> In my case I want to associate each node in the store with an LDAP
>> connection; the node will know the name of the entry it represents, and will
>> know if it knows about any subordinate entries in the LDAP directory.
> <snip/>
>> None of the examples I've looked at (monodoc, gtk-sharp/samples) seem
>> terribly oriented towards data that isn't all known at model creation time.
> Look at the ManagedTreeViewDemo.cs file.  The basic idea is that you:
>  1. Store a custom data type in a TreeStore
>  2. Set a custom cell renderer for the column to properly render the
>     custom data type used in (1).

Thanks for this. I'd looked at that example and for some reason decided it
wasn't useful :-) Of course it does help.

> You can also look at Type Reflector (Mono CVS module: type-reflector) in
> displayers/gtk/GtkTypeDisplayer.cs.  Look at the TreeCell class and the
> OnRenderCellText() function.

Ah, very useful. You seem to be adding parent entries into your TreeStore
with dummy child entries and when the row is expanded you remove the dummy
and add real children.

Presumably the dummy entry's there to fool the view into displaying the
twisty triangle?

That would probably *nearly* work for me, except that my nodes might not
have children when they're expanded, but I don't really want to lose the
twisty in case children are added later on.