三态复选框中的WinForms TreeView控件 [英] Tri-State Checkboxes in WinForms TreeView

查看:488
本文介绍了三态复选框中的WinForms TreeView控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个TreeView,允许用户通过选中或取消选中每个项目的复选框以选择分层数据的某些元素。目前,我禁用显示有使用复选框隐藏技术从子节点盒另一个问题,像这样:

I have a TreeView that allows users to select certain elements of hierarchical data by checking or un-checking each item's checkbox. Currently I disable the box on nodes that have children using the checkbox hiding technique from another question, like so:

☑ Node 1
☐ Node 2
• Node 3
  ☑ Node 3.1
  ☑ Node 3.2
• Node 4
  ☐ Node 4.1
  ☑ Node 4.2

但是,一个更好的解决办法是使用三态复选框的父节点,如:

But a better solution would be to use tri-state check boxes for the parent nodes, like this:

☑ Node 1
☐ Node 2
☑ Node 3
  ☑ Node 3.1
  ☑ Node 3.2
☒ Node 4
  ☐ Node 4.1
  ☑ Node 4.2

由于此功能是在Win32中可用,我问题是如何使用href=\"http://www.codeproject.com/KB/tree/treeviewex2003.aspx?display=Print\">做到不拉箱子我自己(例如,作为用户绘制控件或)。我不熟悉的Win32 API在所有;如何总会有扩展上面链接,以便在有管理的TreeView控件三态checboxes技术?

Since this functionality was available in Win32, my question is how to do this without drawing the boxes myself (e.g., as a user-drawn control or using an image list). I am not familiar with the Win32 API at all; how would one extend the technique linked above to enable tri-state checboxes on a managed TreeView control?

推荐答案

你最近有没有看在?这似乎做的工作。这可能是一个有点过时,(貌似文章是从2004年),但我敢肯定,同样的原理可以扩展到任何你需要做的。

Have you taken a look at this? It seems to do the job. It might be a bit dated, (looks like the article is from 2004), but I'm sure the same principles can be extended to whatever you need to do.

这篇关于三态复选框中的WinForms TreeView控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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