我使用一个包含 ListView 的简单表单创建了新的 Windows 窗体应用程序 (C#)。然后我改变了查看房产 http://msdn.microsoft.com/en-us/library/system.windows.forms.listview.view.aspx更改为“详细信息”并增加了此 ListView 中使用的字体大小,结果如下:
This is how it looks on Windows XP with Windows Classic theme:
and here's the result with Windows XP theme:
I can prevent the appearance of my application to be affected by Visual Styles either by removing Application.EnableVisualStyles() http://msdn.microsoft.com/en-us/library/system.windows.forms.application.enablevisualstyles.aspx call or by changing the
Application.VisualStyleState http://msdn.microsoft.com/en-us/library/system.windows.forms.visualstyles.visualstylestate.aspx:
Although this change makes the ListView to have the desired appearance, it also affects the appearance of other controls. I'd like my ListView to be the only control that is not affected by Visual Styles.
我还发现了类似的问题试图解决它:
您可以仅关闭单个窗口控件的视觉样式/主题吗? https://stackoverflow.com/q/544203/1168156
如何仅禁用一个控件而不是其子控件的视觉样式? https://stackoverflow.com/q/298486/1168156
不幸的是,上述解决方案均无效。看起来标题本身将由一些受视觉样式影响的控件组成,即使 ListView 控件的视觉样式被禁用也是如此。
任何能够防止视觉样式影响 ListView 标头外观的 C# 解决方案都将受到赞赏。
看起来这是一个已知错误 http://www.pcreview.co.uk/forums/listview-columnheader-cutting-off-font-not-big-enough-t1325223.html对此没有简单的解决方法。根据那里的答案:
在对这个问题进行了大量研究之后,我们发现这是一个
Windows 操作系统错误,ComCtl6.0 标头控件忘记应用该错误
将字体信息传递给绘图 DC。
但是您可以自己绘制列标题。看MSDN 上的这篇文章 http://msdn.microsoft.com/en-us/library/system.windows.forms.listview.ownerdraw.aspx有关如何操作的详细信息,还可以查看listView1_DrawColumnHeader
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)