问题
With 2 columns, everything works correct, all the background in the TreeView is white.
But as soon as I add a third column (all three are default CellRendererText), the rows in the first one suddenly have a light grey background.
To show what I mean, I have uploaded a picture:
As you can see at the red arrow, the background in the first column is grey. I have NOT set this anywhere, so why does it do that? It looks really ugly.
As you can see at the blue arrow, I have set the background color of the CellTextRenderer at that row to white. Unfortunately, it only sets the immediate space around the letters white, so the rest of grey remains.
The green arrow points to the third column, which works correctly.
.
As a workaround, I tried inserting an empty column in front of the first column.
It is still the old first column (now second) that had grey background. So there must be something special about that column. Could it be that the column has grey background because it is sorted? It really is the only difference between that column and the others.
Any idea what causes this and how it can be prevented?
回答1:
I came back to the problem after some weeks and figured out that it was this line causing the grey background:
column.SortIndicator = true;
I'm pretty sure that this is intended to only show the little triangle at the top of the row, but due to some bug (I guess) it also kind of marks the whole column under certain circumstances.
Anyway, removing that line fixed the problem. :)
来源:https://stackoverflow.com/questions/9653485/treeview-column-suddenly-grey