Click here to Skip to main content
15,896,557 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 232.6K   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

 
GeneralDeep Logic bug about selecting node(s) Pin
Le_MuLoT13-Sep-05 4:17
Le_MuLoT13-Sep-05 4:17 
AnswerRe: Deep Logic bug about selecting node(s) Pin
Mikael Wiberg14-Sep-05 2:04
Mikael Wiberg14-Sep-05 2:04 
GeneralRe: Deep Logic bug about selecting node(s) Pin
Le_MuLoT14-Sep-05 3:13
Le_MuLoT14-Sep-05 3:13 
GeneralRe: Deep Logic bug about selecting node(s) Pin
Mikael Wiberg14-Sep-05 3:51
Mikael Wiberg14-Sep-05 3:51 
GeneralRe: Deep Logic bug about selecting node(s) Pin
Le_MuLoT14-Sep-05 7:12
Le_MuLoT14-Sep-05 7:12 
GeneralRe: Deep Logic bug about selecting node(s) Pin
Mikael Wiberg14-Sep-05 10:13
Mikael Wiberg14-Sep-05 10:13 
GeneralProjectfiles for VS 2002 Pin
anderslundsgard7-May-05 9:55
anderslundsgard7-May-05 9:55 
GeneralRe: Projectfiles for VS 2002 Pin
Mikael Wiberg7-May-05 21:44
Mikael Wiberg7-May-05 21:44 
I will assume that you are using .NET Framework v1.1 (that is possible with VS 2002 isn't it?).

Unfortunately this requires some manual file copying etc:
You just create a new solution in VS called MWTreeViewTestApp and add a new Windows Control Library project which you call MWTreeView.
When this has been created you can remove the .cs file that is created by default (not AssemblyInfo.cs). Then copy all the .cs and .txt files from my solution directory into your new one using Windows Explorer. Do not copy any .resx, .csproj, .suo or other files.
Click on the project in the Solution Explorer of VS and a little icon will appear just below the name 'Solution Explorer - MWTreeView'. This icon is called 'Show All Files'. Now you will see all the files you manually copied from my solution directory tou yours. Right click on these files and select 'Include In Project'. When this has been done for all the files, you should be able to compile the project/solution.
The same procedure can be performed for the MWTreeViewTestApp project which is a Windows Application project added to the same solution. This will also have to have the Images directory copied intact.
In the MWTreeViewTestApp there is also one ImageList (ilMWTreeView) that you need to add Images to. The images should be 001.jpg and 002.jpg from the Images directory.
If you right-click on the projects and click Properties you can also enter 'MWControlSuite' as the Default Namespace.

Now you should have an MWTreeView and MWTreeViewTestApp that are the same as the ones for VS 2003.

Maybe there is even some converter application that has been written. I don't really know.

If you are using .NET Framework v1.0 I really suggest you upgrade since there is a bug in the MS TreeView that, if I remember correctly, raises the OnMouseUp event straight after the OnMouseDown event. I had a workaround for this in an older version of the MWTreeView, but I don't think I could achieve all the functionality in the MWTreeView v2 using .NET Framework v1.0.

GeneralBuggy ForeColor Pin
Marco Tenuti4-May-05 3:02
Marco Tenuti4-May-05 3:02 
GeneralRe: Buggy ForeColor Pin
Mikael Wiberg4-May-05 4:10
Mikael Wiberg4-May-05 4:10 
GeneralAsk help about two treeviews Operation! Pin
davidsoftware8-Jan-05 16:41
davidsoftware8-Jan-05 16:41 
GeneralRe: Ask help about two treeviews Operation! Pin
Mikael Wiberg9-Jan-05 8:03
Mikael Wiberg9-Jan-05 8:03 
GeneralRe: Ask help about two treeviews Operation! Pin
davidsoftware10-Jan-05 20:39
davidsoftware10-Jan-05 20:39 
GeneralRe: Ask help about two treeviews Operation! Pin
Le_MuLoT8-Sep-05 11:24
Le_MuLoT8-Sep-05 11:24 
AnswerRe: Ask help about two treeviews Operation! Pin
Le_MuLoT9-Sep-05 10:29
Le_MuLoT9-Sep-05 10:29 
GeneralRe: Ask help about two treeviews Operation! Pin
Mikael Wiberg10-Sep-05 2:55
Mikael Wiberg10-Sep-05 2:55 
AnswerRe: Ask help about two treeviews Operation! Pin
Le_MuLoT11-Sep-05 6:07
Le_MuLoT11-Sep-05 6:07 
GeneralRe: Ask help about two treeviews Operation! Pin
Mikael Wiberg11-Sep-05 7:08
Mikael Wiberg11-Sep-05 7:08 
GeneralRe: Ask help about two treeviews Operation! Pin
Le_MuLoT11-Sep-05 10:11
Le_MuLoT11-Sep-05 10:11 
GeneralRe: Ask help about two treeviews Operation! Pin
Mikael Wiberg11-Sep-05 10:45
Mikael Wiberg11-Sep-05 10:45 
GeneralRe: Ask help about two treeviews Operation! Pin
Le_MuLoT11-Sep-05 12:56
Le_MuLoT11-Sep-05 12:56 
GeneralRe: Ask help about two treeviews Operation! Pin
Mikael Wiberg11-Sep-05 17:52
Mikael Wiberg11-Sep-05 17:52 
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 

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.