Allow multi-select in a .NET TreeView

后端 未结 6 1536
太阳男子
太阳男子 2020-12-06 00:02

I\'m stuck in .NET 2.0 Windows Forms.

It doesn\'t look like the ability to select multiple nodes exists in the standard TreeView control.

I\'m t

6条回答
  •  既然无缘
    2020-12-06 00:20

    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.

    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.

提交回复
热议问题