以编程方式在树视图中显示特定节点的showplusminus [英] showplusminus for specific node in treeview programatically

查看:86
本文介绍了以编程方式在树视图中显示特定节点的showplusminus的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上我有以编程方式加载的treeview,这是3级树视图



dept

|

| _Subdept

|

|

| __KPI



加载所有这些值来自database.I我想只为dept和subdept节点showplusminus签名。

我该怎么办?

actually i have treeview which loaded programatically ,this is 3level treeview

dept
|
|_Subdept
|
|
|__KPI

all these value are loaded from database.I want to showplusminus sign only for dept and subdept node.
What can I do?

推荐答案

使用Microsoft WinForms TreeView :请记住,此Control是本机Window TreeView的包装:显示或隐藏,只能为整个Control设置加/减符号。



1将TreeView属性'ShowPlusMinus设置为false。



2.在表单中添加ImageList控件



3.将正负图像添加到ImageList



4.将TreeView的ImageList属性设置为使用ImageList



5.将所选TreeNodes的ImageIndex属性设置为期望



6.实现代码以检测何时显示正在加/减符号的TreeNodes被展开或通过切换ImageIndex折叠。



请记住,一旦将有效的ImageList分配给TreeView,默认情况下,所有节点都将显示ImageList中的第一个图像。



这会产生一个问题:你不能拥有一个没有图像的节点。人们已经找到了解决这个问题的各种尴尬方法:[ ^ ]。



CodeProject有一篇文章说通过创建一个所有者绘制的TreeView来解决这个关于Nodes问题的全有或全无图像:[ ^ ]。



Imho,实施任何费用上述解决方案中的解决方案太高了。 MS TreeView的这些限制是我使用商业第三方TreeView控件(我从Lidor Systems购买了IntegralUI TreeView)切换到的一个(很多)原因。
Using the Microsoft WinForms TreeView: remember that this Control is a wrapper around the native Window TreeView: showing, or hiding, the plus/minus symbols can be set only for the entire Control.

1. set the TreeView Property 'ShowPlusMinus to false.

2. add an ImageList Control to your Form

3. add images for plus and minus to the ImageList

4. set the TreeView 'ImageList Property to use the ImageList

5. set the ImageIndex Property of selected TreeNodes as desired

6. implement code to detect when TreeNodes you wish to show the Plus/Minus symbols on are expanded, or collapsed by switching the ImageIndex.

Keep in mind that once a valid ImageList is assigned to the TreeView, all Nodes will, by default, display the first image in the ImageList.

That creates a problem: you can't have a Node that has no image. People have found various awkward ways to work-around this: [^].

CodeProject has an article that works around this all-or-nothing images on Nodes problem by creating an owner-drawn TreeView: [^].

Imho, the cost of implementing any of the solutions described above is too high. These kinds of limitations on the MS TreeView are one (of many) reasons I switched to using a commercial third-party TreeView Control (I purchased the IntegralUI TreeView from Lidor Systems).


这篇关于以编程方式在树视图中显示特定节点的showplusminus的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆