2016-05-12 59 views
0

我有HeaderUsesThemes錯誤。當我'編輯列'我可以設置每個頭的forecolor屬性就好了,但沒有屬性的背面顏色。ObjectListView標題BackColor

如何設置標題的背景顏色?

+0

你有什麼已經研究過?什麼,特別是不適合你? –

回答

1

與ObjectListView,您可以使用HeaderFormatStyle類更改標題的背面顏色。

下面是一個簡單的例子(更改所有標題使用DarkBlue作爲背景色和灰色的文字相同的風格):

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; 
     } 
} 

OLV是ObjectListView對象

詳細信息可在ObjectListView被發現食譜: http://objectlistview.sourceforge.net/cs/recipes.html#how-do-i-change-the-font-or-color-of-the-column-headers

希望這有助於...