How can I change the expand/collapse images from the plus ( + ) and minus ( - ) images that appear when ShowPlusMinus and/or ShowRootLines are true.
To help visualize, I would like to make the following TreeView

Look like this (like Windows explorer)

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
Depicts what it looks like before and after calling SetWindowTheme
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With