简体   繁体   中英

Adjusting header row color

I use objectlistview in my project, in constructor I have a code like this:

foreach (OLVColumn item in olv.AllColumns)
{
    item.Width = -2;
    var headerstyle = new HeaderFormatStyle();
    headerstyle.SetFont(new Font(new FontFamily("Segoe UI"), 12.0f, FontStyle.Bold));
    headerstyle.SetBackColor(Color.FromArgb(16, 16, 16));
    headerstyle.SetForeColor(Color.White);
    item.HeaderFormatStyle = headerstyle;
}

This code gives a nice backcolor to my rows and sets the default values. This works and result is like this:

在此处输入图像描述

But at the end of the header row there is this: 在此处输入图像描述

There is a small gap with white(default) background color. I can fix this with making category column size a little bit bigger but the user is allowed to hide and change width of columns so this wont solve my problem. How can I reach to that white spot in code? I have checked http://objectlistview.sourceforge.net/cs/recipes.html#how-do-i-change-the-font-or-color-of-the-column-headers but could not find the solution.

It is possible to make a column automatically fill the free horizontal space by setting the property FillsFreeSpace to true .

If it is not desirable to have one of the main columns stretching to the total width, a dummy column (with empty header text) that has FillsFreeSpace set to true could be inserted as the last column. it would probably be advisable to set Hideable and IsEditable to false for that column.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM