Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple selection in a TreeView

I am using a Windows Forms TreeView control in my program. I would like to allow the user to select multiple nodes at the same level by dragging their mouse pointer around (also called a "lasso" selection). I don't think a standard TreeView allows that.

My question is what would be the best way to achieve this? Do I have to write custom selection behaviour of my own in perhaps a custom or derived control? Where do I start?

I don't need a detailed explanation. Just a small nudge in the right direction.

like image 859
Frederick The Fool Avatar asked Nov 03 '09 06:11

Frederick The Fool


People also ask

What is TreeView control explain?

A tree-view control is a window that displays a hierarchical list of items, such as the headings in a document, the entries in an index, or the files and directories on a disk. Each item consists of a label and an optional bitmapped image, and each item can have a list of subitems associated with it.

How do you edit TreeView?

TreeView enables you to edit nodes in applications, you need to set the AllowEditing property of the C1TreeView class to true. The default value of the property is false. You can start editing a node by selecting a node and pressing the Enter or F2 key, or simply double-clicking the node itself.

Which property in the TreeView control represent the node?

The TreeNode class represents a node of a TreeView.


1 Answers

This is not going to be easy to do with a standard WinForms TreeView control. The TreeView control only supports single selection per tree. It is not possible to simultaneously select multiple nodes in the tree.

In order to get this behavior you would likely end up needing to create a very similar class to TreeView which allowed for multiple selection. Another option is to derive from TreeView and enable multiple selection by overriding specific behaviors. Here is an article on how to do the latter.

  • http://www.arstdesign.com/articles/treeviewms.html
like image 131
JaredPar Avatar answered Oct 19 '22 12:10

JaredPar