允许在.NET TreeView中进行多重选择 [英] Allow multi-select in a .NET TreeView

查看:69
本文介绍了允许在.NET TreeView中进行多重选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我陷于.NET 2.0 Windows窗体中。

I'm stuck in .NET 2.0 Windows Forms.

在标准 TreeView 控件。

我正在尝试执行上下文菜单选择。因此,这里的复选框不是可接受的UI范式。

I'm trying to do this for a context menu selection. So check boxes aren't an acceptable UI paradigm here.

提供这种非常必要的功能的最佳方法是什么?

What's the best way to provide that very necessary functionality?

推荐答案

我们曾经在WTL项目中进行过此操作,但是所需的基本工作与.NET相同。要实现多选树控件,您将需要自己绘制树项目并覆盖键盘和鼠标处理。您还需要维护自己选择的项目的列表。

We did this in a WTL project once, but the basic work needed is the same for .NET. To achieve a multiple selection tree control, you will need to draw the tree items yourself and override the keyboard and mouse handling. You will also need to maintain your own list of items that are selected.

别忘了考虑选择规则(例如,允许父母和孩子),以及不要忘记实现键盘快捷键,包括使用Ctrl,Shift和Ctrl + Shift进行选择,以及用于选择/取消选择的空格键。

Don't forget to consider selection rules (are parents and children allowed, for example), and don't forget to implement the keyboard shortcuts including selection using Ctrl, Shift, and Ctrl+Shift, as well as the Spacebar for selecting/deselecting.

这篇关于允许在.NET TreeView中进行多重选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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