开发者

C# ColumnHeader's free space background color

开发者 https://www.devze.com 2022-12-18 13:24 出处:网络
I\'m trying to draw custom ColumnHeaders in a FastObjectListView control. So far the code works, but the ColumnHeaders free space ( so the part that does not contain any column headers atm ) still dr

I'm trying to draw custom ColumnHeaders in a FastObjectListView control.

So far the code works, but the ColumnHeaders free space ( so the part that does not contain any column headers atm ) still draws as default.

    private void olvMain_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
    {
        e.Graphics.FillRectangle(Brushes.Black,
            e.Bounds.X, e.Bounds.Y,
            e.Bounds.Width, e.Bounds.Height);

        e.Graphics.DrawRectangle(Pens.Lime,
            e开发者_运维百科.Bounds.X - 1, e.Bounds.Y - 1,
            e.Bounds.Width - 1, e.Bounds.Height - 1);

        e.DrawText();

        e.DrawDefault = false;
    }

I added:

e.DrawDefault = false;

because without that the columnheaders default style got drawn on top of my custom style, but as the columnheaderbar's free space doesn't contain any columnheaders it's still drawn by it's default style.

Here's a pic to clarify what I mean by Columnheader's free space: Image Link

Thanks in advance.


The area that is not painted black is outside of the headers client area -- thus not paintable by the control.

There is no easy way to change the color of that area. Have a look at this question and its answer to see some possible solutions.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号