Windows theme affecting ListView header

Posted by LihO on Stack Overflow See other posts from Stack Overflow or by LihO
Published on 2012-04-11T09:52:24Z Indexed on 2012/04/16 11:29 UTC
Read the original article Hit count: 309

I've created new Windows Forms Application (C#) with one simple form containing ListView. Then I changed the View Property to Details and increased the size of the font used in this ListView and here's the result:

This is how it looks on Windows XP with Windows Classic theme:
enter image description here

and here's the result with Windows XP theme:
enter image description here

Creating the same Windows Forms Application in Visual C++ instead of C# yields same result.

EDIT :

Thanks to Kamil Lach, we already know that Visual Styles is what makes the appearance of ListView change. This can be avoided either by removing Application.EnableVisualStyles() call or by changing the Application.VisualStyleState. Both of these solutions yield the following result:
enter image description here
This looks fine, but this change affects the appearance of other controls which is not good. I'd like my ListView to be the only control that is not affected by Visual Styles.

I've also found similar questions that try to deal with it:
Can you turn off visual styles/theming for just a single windows control?
How do I disable visual styles for just one control, and not its children?

Unfortunately, none of mentioned solutions works.

Any C# solution that would make the ListView header have the correct height would be appreciated.

© Stack Overflow or respective owner

Related posts about winforms

Related posts about visual-c++