[Gtk-sharp-list] TreeView: changing a row background color?

Joshua Kessler jkessler@eRealty.com
04 Aug 2003 14:46:57 -0500

I am trying to change the background color of different rows on a
treeview of a liststore but I am having a problem figuring out how to do

I read somewhere that you can add a column of type Gdk.Color to the
liststore and then associate the cellrenderer background value to that
column but I am not having any luck.

Here is a small code snippet that may help you guys figure this out.

Gtk.ListStore myListStore = new Gtk.ListStore(
typeof(string),typeof(Gdk.Color) );
Gtk.TreeView myTreeView = new Gtk.TreeView(myListStore);

Gtk.TreeViewColumn myCol = new Gtk.TreeViewColumn();
Gtk.CellRendererText myRend = new Gtk.CellRendererText();

myCol.PackStart(myRend, true);
myCol.AddAttribute(myRend, "text", 0);
myCol.AddAttribute(myRend, "background", 1);


Gtk.TreeIter myRow;
myRow = myListStore.AppendValues("test", new Gdk.Color(0,0,75) );

The error i get is at runtime.

Unhandled Exception: System.Exception: Unknown type
in <0x0011c> 00 Gtk.ListStore:.ctor (System.Type[])

Is there any other way to do this?


Joshua Kessler <jkessler@eRealty.com>