Click here to Skip to main content
15,889,867 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.8K   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

 
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 
The way I have done drag & drop is by having a collection of TreeNodes that are passed (or actually MWTreeNodeWrappers).

By passing this in the drag & drop EventHandlers I get more than just the Text of the TreeNode(s); I can see if they are selected, should be expanded, BackColor, ForeColor, Font and all the other Properties that TreeNodes have.

When I do a drag & drop operation between two different applications and I debug in the one that the TreeNodes are dropped into (inside the OnDragDrop EventHandler) I can get my MWTreeNodeWrapper (mwtnw) out of the collection I am using. But when I put mwtnw into a Watch in Visual Studio, expand it and check the Node Property (where the TreeNode is) this is what I see:
System.Runtime.Remoting.Proxies.__TransparentProxy

And mwtnw.Node.Text contains this:
error: an exception of type: {System.Runtime.Remoting.RemotingException} occurred

I then get an exception with the following Message (when I try to access mwtnw.Node e.g.):
This remoting proxy has no channel sink which means either the server has no registered server channels that are listening, or this application has no suitable client channel to talk to the server.

If I understand this correctly it means that I cannot do it because the TreeNode cannot be serialized which is what is required by a drag & drop operation between two separate applications.

Please tell me if I am doing something wrong here or if I have not understood how it should properly be done.

Have you tried doing this yourself? If so I would be very happy if you could send me some very simple (or not so simple, it doesn't really matter) test app that does this, and then I will investigate Smile | :)
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 
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 
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.