Expanding on Ivan Ičin's solution :
[DllImport("uxtheme.dll", ExactSpelling = true, CharSet = CharSet.Unicode)]
private static extern int SetWindowTheme(IntPtr hwnd, string pszSubAppName, string pszSubIdList);
public static void SetTreeViewTheme(IntPtr treeHandle) {
SetWindowTheme(treeHandle, "explorer", null);
}
To use, add a TreeView
to your form, and in Form_Load
:
SetTreeViewTheme( treeView1.Handle );
Alternatively, you can extend the TreeView object
public class MyTreeView : TreeView
{
[DllImport("uxtheme.dll", ExactSpelling = true, CharSet = CharSet.Unicode)]
private static extern int SetWindowTheme(IntPtr hwnd, string pszSubAppName, string pszSubIdList);
public MyTreeView() {
SetWindowTheme(this.Handle, "explorer", null);
}
}
Depicts what it looks like before and after calling SetWindowTheme