TreeView:列突然变为灰色 [英] TreeView: Column suddenly grey

查看:81
本文介绍了TreeView:列突然变为灰色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有2列,一切正常,TreeView中的所有背景均为白色.

With 2 columns, everything works correct, all the background in the TreeView is white.

但是,一旦我添加了第三列(所有三列都是默认的CellRendererText),第一列中的行就会突然变成浅灰色背景.

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.

正如您在蓝色箭头中看到的那样,我已将该行的CellTextRenderer的背景色设置为白色.不幸的是,它仅将字母周围的立即空间设置为白色,因此其余的灰色仍然保留.

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?

推荐答案

几周后我又回到问题上来,发现这是导致灰色背景的那一行:

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. :)

这篇关于TreeView:列突然变为灰色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆