如何将treeView组件的主题更改为文件夹和文件图标(Windows主题)

时间:2019-07-18 10:14:17

标签: c# winforms treeview windows-themes

我正在使用winForm。 我正在尝试将treeView组件的主题更改为Windows主题,我看到@David Heffernan回答了这种问题:How to get Windows native look for the .NET TreeView? 但我不完全了解。

我尝试了他的答案,但没有成功:加号/减号更改为“三角形”节点句柄,蓝色常规正方形更改为“气泡”选择正方形,但不会将文件夹/文件更改为Windows \资源管理器中的图标。 我需要在他的代码中添加什么才能显示图标?

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

0 个答案:

没有答案
相关问题