如何更改我的树视图图标 insted +,- 就像 c#.net win 窗体中的 Windows 资源管理器树视图 [英] How to change my treeView icons insted of +,- like a windows explorer treeview in c#.net win forms
本文介绍了如何更改我的树视图图标 insted +,- 就像 c#.net win 窗体中的 Windows 资源管理器树视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何更改当 ShowPlusMinus
和/或 ShowRootLines
为 时出现的加号 ( + ) 和减号 ( - ) 图像的展开/折叠图像真的
.
为了帮助可视化,我想制作以下 TreeView
看起来像这样(像 Windows 资源管理器)
解决方案
扩展 描述调用SetWindowTheme
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 SetWindowTheme
这篇关于如何更改我的树视图图标 insted +,- 就像 c#.net win 窗体中的 Windows 资源管理器树视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文