[Gtk-sharp-list] How to Give a TreeView Row a Different Color?

Andy York andy at brdstudio.net
Sun May 9 14:20:15 EDT 2010


Jacek,

In Gtk it is not common to alter the row color as it is controlled by 
the currently installed theme. I have had minor success with altering 
the appearance of widgets without changing the theme but it has been a 
frustrating task to say the least. I'm sorry I don't have a solution 
that is useful enough to pass on but I thought you may want to know that 
it is not common to go against the theme so it can be aggravating. But I 
will say your on the right path, try browsing Banshee's source code they 
have done quite a bit with TreeViews.

I hope this is at least a little helpful.

SpoodyGoon



On 5/9/2010 1:18 PM, Jacek Ruz.yczka wrote:
> Hi folks,
>
> I am fighting with a not-so-strange wish: I have a TreeView with a TreeStore
> behind it, and now I wanna give a newly-inserted row (!!) a different
> color...for instance, white letters on red background. For another TreeView
> with ListStore, this code already works fine:
>
> 		private void MarkErrorRow (int row)
> 		{
> 			foreach (TreeViewColumn column in this.itemTreeView.Columns) {
> 				CellRendererText cell = (CellRendererText) column.CellRenderers [row];
> 				cell.ForegroundGdk = new Color((byte) 0xFF, (byte) 0xFF, (byte) 0xFF);
> 				cell.BackgroundGdk = new Color((byte) 0xFF, (byte) 0x00, (byte) 0x00);
> 			}
> 		}
>
> But when I try to use the same code in conjunction with a TreeStore, I always
> get a crash 'cause the CellRenderers array only contains one single item.
>
> Even worse: I really use the "tree" functionality of the TreeStore, and
> sometimes I have to "paint" child rows, too.
>
> Any suggestions?
>
> Regards
> Jacek
>
> ----------------------------------------------------------------------
> Audi kilka tysiÄ^(TM)cy zÅ,otych taniej? Przebieraj wÅ>ród tysiÄ^(TM)cy ogÅ,oszeÅ"!
> Sprawdz>>>  http://linkint.pl/f26b3
>
>    
>
>
> _______________________________________________
> Gtk-sharp-list maillist  -  Gtk-sharp-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
>    
>
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 9.0.819 / Virus Database: 271.1.1/2863 - Release Date: 05/09/10 02:26:00
>
>    
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20100509/128968b8/attachment.html 


More information about the Gtk-sharp-list mailing list