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

Jacek Rużyczka stacheldraht at interia.pl
Sun May 9 13:18:18 EDT 2010


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ęcy złotych taniej? Przebieraj wśród tysięcy ogłoszeń!
Sprawdz >>> http://linkint.pl/f26b3



More information about the Gtk-sharp-list mailing list