2010-12-16 56 views
8

当我在VS2008的细节视图中创建一个ListView时,它创建了一个相当老看的listview。它没有任何幻想悬停效果和酷蓝色边框(例如)WinVista和Win7中的文件浏览器。例如: alt textC#Windows7/Vista风格ListView

所以总结一下,我怎样才能在C#VS2008中获得一个ListView,看起来像上图中的那个? (上比较正确的VS2008列表视图)

感谢

回答

13

尝试调用SetWindowTheme

像这样:

[DllImport("uxtheme.dll", ExactSpelling=true, CharSet=CharSet.Unicode)] 
    private static extern int SetWindowTheme(IntPtr hwnd, string pszSubAppName, string pszSubIdList); 

    // The constructor: 
    public MyForm() { 
     SetWindowTheme(this.listView1.Handle, "Explorer", null); 
    } 
+0

谢谢,完美的工作:) – Ozzy 2010-12-16 16:46:13

+0

@GvS:有没有办法为你的整个应用程序做到这一点?像Applicaiton.EnableVisualStyles()? – 2011-12-13 21:12:55

+0

您可能还想设置“HotTracking”以启用酷炫的悬停风格。 @JohnGietzen只想到我能想到的是寻找WM_CREATE的[自定义消息过滤器](http://msdn.microsoft.com/en-us/library/system.windows.forms.application.addmessagefilter.aspx)。 – jnm2 2014-10-29 18:51:16

0

你检查​​?它有很多Win7风格的控件。我认为它有你想要的。