Click here to Skip to main content
15,887,596 members
Articles / Programming Languages / XML

Multi-select Treeview control v2.0

Rate me:
Please Sign up or sign in to vote.
4.64/5 (16 votes)
15 Aug 2004CPOL 230.7K   6.2K   48   52
Multi-select Treeview control v2.0

Screenshots

Image 1

Image 2

Image 3

Image 4

Image 5

Image 6

Image 7

Image 8

Image 9

Introduction

This is a multi select TreeView Control for the .NET Framework. It is possible to select TreeNodes in multiple ways with or without constraints.

Details

The MWTreeView has a few ways of mouse-selecting the TreeNodes by painting anything from a rubberband to very graphical representations. There is even the possibility, using GDI+, to customize the mouse-selection. It is also possible to have TreeNodes of various colors within the same MWTreeView with multi-selection still working. The MWTreeView has a massive amount of configurable settings so that anyone should be able to tailor it to their needs.

Note that when selecting TreeNodes in code, the SelectNode (DeselectNode also exists) method should be used. Note that when changing the colors of a TreeNode, the ChangeColors method should be used. Do not just change the colors of a TreeNode.

Note that in order to iterate through the selected TreeNodes, the following method has to be used (selected TreeNodes are stored in a Hashtable):

C#
foreach(MWTreeNodeWrapper mwtnw in mwtvMWTreeView.SelNodes.Values)
{
   MessageBox.Show("The " + mwtnw.Node.Text + 
    " TreeNode is selected.");
}

Contacting Me

I can be reached through the forum here at CodeProject.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Sweden Sweden
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralRe: Ask help about two treeviews Operation! Pin
Le_MuLoT12-Sep-05 6:21
Le_MuLoT12-Sep-05 6:21 
GeneralAfterSelect not giving TreeViewAction Pin
Racoonzz18-Oct-04 13:10
Racoonzz18-Oct-04 13:10 
GeneralRe: AfterSelect not giving TreeViewAction Pin
Mikael Wiberg19-Oct-04 1:31
Mikael Wiberg19-Oct-04 1:31 
GeneralTech demo - NOT article Pin
Mikael Wiberg16-Aug-04 22:39
Mikael Wiberg16-Aug-04 22:39 
GeneralRe: Tech demo - NOT article Pin
labreuer20-Aug-04 11:16
labreuer20-Aug-04 11:16 
GeneralRe: Tech demo - NOT article Pin
Mikael Wiberg21-Aug-04 9:45
Mikael Wiberg21-Aug-04 9:45 
GeneralRe: Tech demo - NOT article Pin
labreuer22-Aug-04 8:53
labreuer22-Aug-04 8:53 
GeneralRe: Tech demo - NOT article Pin
Mikael Wiberg22-Aug-04 9:43
Mikael Wiberg22-Aug-04 9:43 
There is a little bit of spaghetti code - which in my view unfortunately is inevitable for the TreeView... Let me explain;

The MWTreeView does a lot of (quoting other people) 'very complex things'. It also does this without using any Win32 stuff. In order to be able to provide this kind of functionality for a Control that is written the way the .NET TreeView is (missing events and whatnot) the modification-code has to be 'injected' where the underlying TreeView exposes its 'vitals'.

This is why there is so much code for a lot of the exposed event handlers. And also for a lot of the functionality (where I thought it was important and where I could) I have emulated the TreeView 'to the pixel'.
There are also a lot of things that are not working in the original TreeView which now work in the MWTreeView.

If I did it again I would probably do a lot of things differently though.

You must also understand that this Control has been developed in two 'phases'. One phase a bit over a year ago. Then the new one in the last two to three weeks.

I am not the kind of person who remembers code I wrote a year ago (I have more important things on my mind).
Using the comments in the code for the MWTreeView I was however able to improve it something ridiculously during these last few weeks. Not only adding functionality, but also fixing bugs and improving it in a lot of places.
And if I could do it, anyone else could, using my code comments.

(See the comment from Soliant on the previous 'version' of the MWTreeView: http://www.codeproject.com/cs/miscctrl/mwcontrols.asp#xx823093xx.)
GeneralRe: Tech demo - NOT article Pin
Le_MuLoT9-Sep-05 10:46
Le_MuLoT9-Sep-05 10:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.