ObjectListView 标题背景色

Cha*_*lie 1 objectlistview

我有 HeaderUsesThemes 为假。当我“编辑列”时,我可以很好地设置每个标题的前景色属性,但没有背景色的属性。

如何设置标题的背景颜色?

小智 6

使用 ObjectListView,您可以使用 HeaderFormatStyle 类更改标题的背景颜色。

这是一个简短的示例(使用深蓝色作为背景色和灰色作为文本将所有标题更改为相同的样式):

using System;
//...
using BrightIdeasSoftware;

//...

private void adjustMyObjectListViewHeader()
{
    foreach (OLVColumn item in olv.Columns)
        {
            var headerstyle =  new HeaderFormatStyle();
            headerstyle.SetBackColor(Color.DarkBlue);
            headerstyle.SetForeColor(Color.SlateGray);
            item.HeaderFormatStyle = headerstyle;
        }
}
Run Code Online (Sandbox Code Playgroud)

olv 是 ObjectListView 对象

可以在 ObjectListView Cookbook 中找到详细信息:http : //objectlistview.sourceforge.net/cs/recipes.html#how-do-i-change-the-font-or-color-of-the-column-headers

希望这可以帮助...