0

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

  • If you want to reproduce the Explorer, you can use the Shell built-in **NamespaceTreecontrol** : [Test NamespaceTreecontrol](https://i.ibb.co/5rtPTPK/Name-Space-Tree-Control.jpg) I use it in C++ and VB.NET but I can convert/post a sample in C# if you cannot make it work – Castorix Jul 18 '19 at 10:58
  • Folder and file icons comes from the `ImageList` which you set for your `TreeView`. Use whatever icon you like. – Reza Aghaei Jul 18 '19 at 15:10

0 Answers0