yoav raytsfeld
yoav raytsfeld

Reputation: 1

How to change theme of treeView component to folders and files icons (windows theme)

I'm using winForm. I'm trying to change the theme of treeView component to windows theme, I saw @David Heffernan answer to this kind of question: How to get Windows native look for the .NET TreeView? but I don't fully understand it.

I tried his answer and it half works: the plus/minus sign changed to "triangle" node handles and the blue regular square changed to "bubble" selection square, but it doesn't change the folders/files to windows\explorer icons. What do I need to add to his code to make the icons appear?

public class NativeTreeView : System.Windows.Forms.TreeView
{
    [DllImport("uxtheme.dll", CharSet = CharSet.Unicode)]
    private extern static int SetWindowTheme(IntPtr hWnd, string 
                                           pszSubAppName,string pszSubIdList);

    protected override void CreateHandle()
    {
        base.CreateHandle();
        SetWindowTheme(this.Handle, "explorer", null);
    }
}

desired format

Upvotes: 0

Views: 416

Answers (0)

Related Questions