如何控制在.NET Forms.TreeView复选框? [英] How can I control checkboxes in a .Net Forms.TreeView?

查看:109
本文介绍了如何控制在.NET Forms.TreeView复选框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个TreeView一个.net桌面应用程序的UI元素之一。

I have a .Net desktop application with a TreeView as one of the UI elements.

我希望能够多选择的TreeView,只是不支持的。

I want to be able to multi-select that TreeView, only that isn't supported at all.

所以我加入的复选框的树,我的问题是,只有一些项目是可选择的,和那些没有不能始终如一地级联选择。

So I'm adding check-boxes to the tree, My problem is that only some items are selectable, and those that aren't can't consistently cascade selections.

有没有什么办法来禁用或同时显示其他隐藏一些的复选框?

Is there any way to disable or hide some check-boxes while displaying others?

推荐答案

TreeView控件的默认行为是,当<一href="http://msdn.microsoft.com/en-us/library/system.windows.forms.treeview.checkboxes%28VS.80%29.aspx"相对=nofollow>复选框属性设置为true,复选框将显示所有的树节点来。

The default behavior of TreeView is that when the Checkboxes property is set to true, that checkboxes will be shown for all TreeNodes.

这是你正在寻找的行为 - 禁用或隐藏某些复选框 - 是正常行为的自定义修改。您可以创建一个自定义实现树视图或树节点的覆盖缺省行为。另一件事,试图将是使用TreeView。<一个href="http://msdn.microsoft.com/en-us/library/system.windows.forms.treeview.stateimagelist%28VS.80%29.aspx"相对=nofollow> StateImageList 财产。有些网站签出更多的信息:

The behavior that you are looking for - to disable or hide some checkboxes - is a custom modification of the normal behavior. You can create a custom implementation of TreeView or TreeNode that overrides the default behavior. One other thing to try would be to use the TreeView.StateImageList property. Some sites to check out for more info:

  • See this post to the MSDN forums that goes through an implementation similar to what you are attempting.
  • CodeProject: Tri-State TreeView
  • CodeProject: How to handle custom node state images in a TreeView (e.g. tristate checkboxes)

这篇关于如何控制在.NET Forms.TreeView复选框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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