[Gtk-sharp-list] different color rows for GtkTreeView

Philip Wobst philip.wobst at aastra.com
Thu Feb 19 05:34:00 EST 2009


I was looking for the same thing that Tim was looking for in this thread
-
http://lists.ximian.com/pipermail/gtk-sharp-list/2008-April/008605.html
- and the solutions provided within the thread seemed more complicated
than necessary. 
 
I have found the solution using theme settings:
 
Steps:
1. the Gtk.TreeView.RulesHint property must be set to TRUE (the default
is FALSE). 
See
http://library.gnome.org/devel/gtk/stable/GtkTreeView.html#GtkTreeView--
rules-hint for documentation
 
2. Since the colors can not be set in the application itself (atleast I
found no way to do that in Gtk#) you will need to specify them in a
gtkrc file. If you have your own theme that is loaded by your
application you can specify the colors there (see gtkrc documentation on
how to select themes for your application).
 
3. In the gtkrc file you will now need three setting to activate
alternating row colors
 
style "treeview" {
    GtkTreeView::allow-rules = TRUE
    GtkTreeView::even-row-color = "red"
    GtkTreeView::odd-row-color = "blue"
}
class "GtkTreeView" style "treeview" 

It turned out that both the TreeView and the theme need to have the
rules property set to TRUE for this to work!
 
Philip
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20090219/25d90d74/attachment-0001.html 


More information about the Gtk-sharp-list mailing list