[Gtk-sharp-list] Howto use Treeview Cell Data Function

John BouAntoun secretsquirrel@optusnet.com.au
Sun, 25 Jan 2004 19:08:48 +1100


Thanks dude,

This is exactly what I needed.

Regards,

JBA

On Sun, 2004-01-25 at 18:03, Jonathan Pryor wrote:
> You could take a look at Type Reflector (Mono CVS module:
> type-reflector) for some TreeCellDataFunc use.
> 
> You'll want to see displayers/gtk/GtkTypeDisplayer.cs, in the
> OnRenderCellText and OnRenderCellIcon methods.
> 
> A sample implementation would be:
> 
> 	private void MyCellDataFunc_Column1 (
> 		Gtk.TreeViewColumn tree_column,
> 		Gtk.CellRenderer cell,
> 		Gtk.TreeModel tree_model,
> 		Gtk.TreeIter iter)
> 	{
> 		complexObject co = (complexObject) 
> 			tree_model.GetValue (iter, 0);
> 		((CellRendererText) cell).Text = co.firstString;
> 	}
> 
> You would need to use a different function for each column you wanted
> rendered.
> 
>  - Jon
> 
> On Sat, 2004-01-24 at 08:05, John BouAntoun wrote:
> > Hey guys,
> > 
> > I have treeview that has a liststore of complex objects.
> > 
> > I wanted to map some text cell renderers to different string properties
> > of the complex object.
> > 
> > I figured out that I need a CellDataFunction and have the signature
> > correct, but I have no idea what to do inside the CellDataFunction to
> > get it to render properly.
> > 
> > Some help (an example even) would be much appreciation.
> > 
> > For simplicity's sake lets just say the complex object looked something
> > like this
> > 
> > class complexObject {
> >         string firstString {get;};
> >         string secondString {get;};
> > }
> > 
> > how would I get those two properties to render in the separate columns
> > of a treeview?
> > 
> > Thanks in advance
> > 
> > JBA
> > 
> > 
> > _______________________________________________
> > Gtk-sharp-list maillist  -  Gtk-sharp-list@lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
>