Click here to Skip to main content
Click here to Skip to main content

Tri-State TreeView Control

By , 2 Nov 2005
 

Introduction

Microsoft provides a TreeView control in the .NET framework, but as usual it doesn't expose all the functionality that the underlying common control provides. It has the possibility to display check-boxes but they can't be tri-state check boxes.

This control adds tri-state check boxes and the necessary handling methods to check/uncheck all sub-items if the user clicks on a node, as well as displays a grey-checked check box for the parent if the siblings have differing check/uncheck states.

Background

A tri-state TreeView is a tree view control that displays check boxes next to the tree nodes. If you click on a check box, it checks (or unchecks) the check box and all sub-nodes.

If the nodes on the same level as the clicked node have differing check states the parent node's check box is grey-checked as well as its parent's and so on.

If you click on a grey-checked check box it unchecks that node and all its subnodes.

How to use the control

Add TriStateTreeView.cs to your project and then simply drop the TriStateTreeView control on a form and use it as a regular TreeView control. The only difference is when you want to access the checked state of a node. Instead of using the treeNode.Checked property you call triStateTreeView.GetChecked(treeNode) resp. triStateTreeView.SetChecked(treeNode, checkState). Instead of a bool these methods take a CheckState.

For example, the following code snippet checks the state of all the top level nodes:

foreach (TreeNode node in m_treeView.Nodes)
{
  if (m_treeView.GetChecked(node) == 
         TriStateTreeView.CheckState.Checked)
    DoFoo(node);
}

How does it work?

The control derives from TreeView and sets the ImageList and SelectedImageList properties for the base control. It overrides the OnClick and OnKeyDown methods.

In the OnKeyDown method, we check if the pressed key is a space, and if it is we change the state of the selected node.

The OnClick method is a little trickier. We have to use the TVM_HITTEST Win32 API message to determine if the user clicked on the icon or on the item. If the user clicked on the icon we change the state of the selected node.

Limitations

This control doesn't support displaying both check boxes and icons. If you need this functionality you have to call additional Win32 API methods. The common control tree view control supports having multiple image lists, but this functionality isn't exposed in .NET.

Remarks

The control makes use of the Skybound.VisualStyle assembly from www.skybound.ca. By commenting out the lines that reference that assembly it will easily work without it. Another way of making the control aware of visual styles is described here.

The demo project consists of an assembly that contains the TriStateTreeView, a demo project and a NUnit test assembly with some tests for the control.

History

  • 26 March 2004 - First version.
  • 28 October 2005 - Added support for visual styles and Before/AfterCheck.

License

This article, along with any associated source code and files, is licensed under The Common Public License Version 1.0 (CPL)

About the Author

Ebse
Software Developer (Senior)
Germany Germany
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionHow to use this dll in 64 bit mechinesmemberMember 329057315 Sep '10 - 16:18 
Hi,
 
I tried this dll with my application and application can use this dll in my local mechine(WIndows XP).Then i had deployed the application on 64 bit windows server i got the error message application has stopped working.
 
Problem signature:
Problem Event Name: CLR20r3
Problem Signature 01: tristate.exe
Problem Signature 02: 1.0.0.0
Problem Signature 03: 4c917bd9
Problem Signature 04: tristate
Problem Signature 05: 1.0.0.0
Problem Signature 06: 4c917bd9
Problem Signature 07: 9
Problem Signature 08: 11
Problem Signature 09: System.BadImageFormatException
OS Version: 6.0.6002.2.2.0.274.10
Locale ID: 1033
 
Can you please advice how i can solve this issue
 
Regards,
Sajesh
AnswerRe: How to use this dll in 64 bit mechinesmemberCody Tang7 Oct '10 - 23:30 
Hello Sajesh,
 
I have found how to make it work in x64. Open the source code, and make the following changes in the constructor.
 
public TriStateTreeView()
{
    // This call is required by the Windows.Forms Form Designer.
    InitializeComponent();
 
    if (ThemeInformation.VisualStylesEnabled)
    {
        Bitmap bmp = new Bitmap(m_TriStateImages.ImageSize.Width, m_TriStateImages.ImageSize.Height);
        Rectangle rc = new Rectangle(0, 0, bmp.Width, bmp.Height);
        Graphics graphics = Graphics.FromImage(bmp);
 
        ThemePaint.Draw(graphics, this, ThemeClasses.Button, ThemeParts.ButtonCheckBox, ThemeStates.CheckBoxCheckedDisabled, rc, rc);
        m_TriStateImages.Images[0] = bmp;
 
        ThemePaint.Draw(graphics, this, ThemeClasses.Button, ThemeParts.ButtonCheckBox, ThemeStates.CheckBoxUncheckedNormal, rc, rc);
        m_TriStateImages.Images[1] = bmp;
 
        ThemePaint.Draw(graphics, this, ThemeClasses.Button, ThemeParts.ButtonCheckBox, ThemeStates.CheckBoxCheckedNormal, rc, rc);
        m_TriStateImages.Images[2] = bmp;
    }
 
    ImageList = m_TriStateImages;
    ImageIndex = (int)CheckState.Unchecked;
    SelectedImageIndex = (int)CheckState.Unchecked;
}
 
You can dereference the Skybound.visualstyles.dll. That's all I did to use the control in x64 machines. Hope this helps.
Regards,
Cody

GeneralRe: How to use this dll in 64 bit mechinesmemberMember 223057026 Dec '10 - 12:11 
It Does not work on win7 64x?!?!
could you upload a sample on win 64x
GeneralRe: How to use this dll in 64 bit mechinesmemberCody Tang30 Jul '11 - 21:49 
Hello,
 
If you get the bad image format exception, I think you need to open the source code, remove the reference to SkyVisualBound.dll (follow what I mentioned previously) and build it in "Any CPU".
Regards,
Cody Tang

GeneralRe: How to use this dll in 64 bit mechinesmemberpman30 Jul '11 - 1:01 
worked, thx!
GeneralImage problemmemberDevon Peterson17 Feb '10 - 12:53 
Hi,
 
I'm trying to use this control in a VS 2008 project. I'm able to compile it fine and add it to a test form but when I try to run the application I get a BadImageFormatException. Is there a problem with how I am building the dll or something like that? Has anyone else had this problem and resolved it?
 
I'd appreciate any help I can get,
 
Devon
modified on Wednesday, February 17, 2010 7:00 PM

GeneralRe: Image problemmemberDevon Peterson17 Feb '10 - 13:20 
I've discovered a little more. If I change the build options from Any CPU to x86 then it works. Unfortunately the project I want to integrate this in must build for Any CPU.
 
Any suggestions?
 
Devon
GeneralAdded ability to have disabled nodes. You might find this usefull. [modified]memberMuaddubby17 Jun '09 - 2:49 
As noted in a previous message, I found this control extremely useful, so thx a bunch for that.
 
One thing I was missing, however, was the ability to enable and disable specific tree nodes. Adding an Enabled property to a derived class of the TreeNode would have been too complex because I'd have to inherit from several other classes as well and it would get messy.
 
Instead, I added a DisabledColor property to your TriStateTreeView. Set this property to a particular color (such as SystemColors.GrayText), and then whenever you need to disable a node, set its ForeColor to this color as well. The TriStateTreeView will then properly manage the click states of all parent and child nodes accordingly.
 
I can't find a way to put an attachment here, so I'm forced to paste the class.
 
Hope it comes in handy to someone.
 
[Note: the CodeProject is truncating the pasted code, as I've probably hit a maximum length or something. See my response to this note with the rest of the code.]
 
// ---------------------------------------------------------------------------------------------
#region // Copyright (c) 2004-2005, SIL International. All Rights Reserved.
// <copyright from='2004' to='2005' company='SIL International'>
// Copyright (c) 2004-2005, SIL International. All Rights Reserved.
//
// Distributable under the terms of either the Common Public License or the
// GNU Lesser General Public License, as specified in the LICENSING.txt file.
// </copyright>
#endregion
//
// File: TriStateTreeView.cs
// Responsibility: Eberhard Beilharz/Tim Steenwyk
//
// <remarks>
// Downloaded from the CodeProject, at http://www.codeproject.com/KB/tree/TriStateTreeViewSubmissio.aspx?msg=3054765#xx3054765xx
// </remarks>
// ---------------------------------------------------------------------------------------------
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Runtime.Serialization;
 
namespace WinControls
{
/// ----------------------------------------------------------------------------------------
/// <summary>
/// A tree view with tri-state check boxes
/// </summary>
/// <remarks>
/// REVIEW: If we want to have icons in addition to the check boxes, we probably have to
/// set the icons for the check boxes in a different way. The windows tree view control
/// can have a separate image list for states.
/// </remarks>
/// ----------------------------------------------------------------------------------------
public class TriStateTreeView : TreeView
{
private System.Drawing.Color mDisabledNodeColor;
 
/// <summary>
/// Gets/sets the color of the disabled nodes. Used to tell if a node should be checked off or not.
/// </summary>
public System.Drawing.Color DisabledNodeColor
{
get { return mDisabledNodeColor; }
set { mDisabledNodeColor = value; }
}

private System.Windows.Forms.ImageList m_TriStateImages;
private System.ComponentModel.IContainer components;
/// <summary>
/// The check state
/// </summary>
/// <remarks>The states corresponds to image index</remarks>
public enum CheckState
{
/// <summary>greyed out</summary>
GreyChecked = 0,
/// <summary>Unchecked</summary>
Unchecked = 1,
/// <summary>Checked</summary>
Checked = 2,
}
 
#region Redefined Win-API structs and methods
/// <summary></summary>
[StructLayout(LayoutKind.Sequential, Pack=1)]
public struct TV_HITTESTINFO
{
/// <summary>Client coordinates of the point to test.</summary>
public Point pt;
/// <summary>Variable that receives information about the results of a hit test.</summary>
public TVHit flags;
/// <summary>Handle to the item that occupies the point.</summary>
public IntPtr hItem;
}
 
/// <summary>Hit tests for tree view</summary>
[Flags]
public enum TVHit
{
/// <summary>In the client area, but below the last item.</summary>
NoWhere = 0x0001,
/// <summary>On the bitmap associated with an item.</summary>
OnItemIcon = 0x0002,
/// <summary>On the label (string) associated with an item.</summary>
OnItemLabel = 0x0004,
/// <summary>In the indentation associated with an item.</summary>
OnItemIndent = 0x0008,
/// <summary>On the button associated with an item.</summary>
OnItemButton = 0x0010,
/// <summary>In the area to the right of an item. </summary>
OnItemRight = 0x0020,
/// <summary>On the state icon for a tree-view item that is in a user-defined state.</summary>
OnItemStateIcon = 0x0040,
/// <summary>On the bitmap or label associated with an item. </summary>
OnItem = (OnItemIcon | OnItemLabel | OnItemStateIcon),
/// <summary>Above the client area. </summary>
Above = 0x0100,
/// <summary>Below the client area.</summary>
Below = 0x0200,
/// <summary>To the right of the client area.</summary>
ToRight = 0x0400,
/// <summary>To the left of the client area.</summary>
ToLeft = 0x0800
}
 
/// <summary></summary>
public enum TreeViewMessages
{
/// <summary></summary>
TV_FIRST = 0x1100, // TreeView messages
/// <summary></summary>
TVM_HITTEST = (TV_FIRST + 17),
}
 
/// <summary></summary>
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int SendMessage(IntPtr hWnd, TreeViewMessages msg, int wParam, ref TV_HITTESTINFO lParam);
#endregion
 
#region Constructor and destructor
/// ------------------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the <see cref="TriStateTreeView"/> class.
/// </summary>
/// ------------------------------------------------------------------------------------
public TriStateTreeView()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
mDisabledNodeColor = SystemColors.GrayText;
ImageList = m_TriStateImages;
ImageIndex = (int)CheckState.Unchecked;
SelectedImageIndex = (int)CheckState.Unchecked;
}
 
/// -----------------------------------------------------------------------------------
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing"><c>true</c> to release both managed and unmanaged
/// resources; <c>false</c> to release only unmanaged resources.
/// </param>
/// -----------------------------------------------------------------------------------
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#endregion
 
#region Component Designer generated code
/// -----------------------------------------------------------------------------------
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
/// -----------------------------------------------------------------------------------
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(TriStateTreeView));
this.m_TriStateImages = new System.Windows.Forms.ImageList(this.components);
//
// m_TriStateImages
//
this.m_TriStateImages.ImageSize = new System.Drawing.Size(16, 16);
this.m_TriStateImages.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("m_TriStateImages.ImageStream")));
this.m_TriStateImages.TransparentColor = System.Drawing.Color.Magenta;
 
}
#endregion
 
#region Hide no longer appropriate properties from Designer
/// ------------------------------------------------------------------------------------
/// <summary>
///
/// </summary>
/// ------------------------------------------------------------------------------------
[Browsable(false)]
public new bool CheckBoxes
{
get { return base.CheckBoxes; }
set { base.CheckBoxes = value; }
}
 
/// ------------------------------------------------------------------------------------
/// <summary>
///
/// </summary>
/// ------------------------------------------------------------------------------------
[Browsable(false)]
public new int ImageIndex
{
get { return base.ImageIndex; }
set { base.ImageIndex = value; }
}
 
/// ------------------------------------------------------------------------------------
/// <summary>
///
/// </summary>
/// ------------------------------------------------------------------------------------
[Browsable(false)]
public new ImageList ImageList
{
get { return base.ImageList; }
set { base.ImageList = value; }
}
 
/// ------------------------------------------------------------------------------------
/// <summary>
///
/// </summary>
/// ------------------------------------------------------------------------------------
[Browsable(false)]
public new int SelectedImageIndex
{
get { return base.SelectedImageIndex; }
set { base.SelectedImageIndex = value; }
}
#endregion
 
#region Overrides
/*protected new TriStateTreeNode[] Nodes
{
this.nodes
}*/
/// ------------------------------------------------------------------------------------
/// <summary>
/// Called when the user clicks on an item
/// </summary>
/// <param name="e"></param>
/// ------------------------------------------------------------------------------------
protected override void OnClick(EventArgs e)
{
base.OnClick (e);
 
TV_HITTESTINFO hitTestInfo = new TV_HITTESTINFO();
hitTestInfo.pt = PointToClient(Control.MousePosition);
 
SendMessage(Handle, TreeViewMessages.TVM_HITTEST,
0, ref hitTestInfo);
if ((hitTestInfo.flags & TVHit.OnItemIcon) == TVHit.OnItemIcon)
{
TreeNode node = GetNodeAt(hitTestInfo.pt);
if (node != null)
{
ChangeNodeState(node);
}
}
}
 
/// ------------------------------------------------------------------------------------
/// <summary>
/// Toggle item if user presses space bar
/// </summary>
/// <param name="e"></param>
/// ------------------------------------------------------------------------------------
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown (e);
 
if (e.KeyCode == Keys.Space)
ChangeNodeState(SelectedNode);
}
#endregion
 
#region Private methods
/// ------------------------------------------------------------------------------------
/// <summary>
/// Checks or unchecks all children
/// </summary>
/// <param name="node"></param>
/// <param name="state"></param>
/// ------------------------------------------------------------------------------------
private void CheckNode(TreeNode node, CheckState state)
{
bool checkSet = InternalSetChecked(node, state);
 
if (checkSet)
{
foreach (TreeNode child in node.Nodes)
{
CheckNode(child, state);
}
}
 
ChangeParent(node.Parent);
}
 
/// ------------------------------------------------------------------------------------
/// <summary>
/// Called after a node changed its state. Has to go through all direct children and
/// set state based on children's state.
/// </summary>
/// <param name="node">Parent node</param>
/// ------------------------------------------------------------------------------------
private void ChangeParent(TreeNode node)
{
if (node == null)
{
return;
}
 
CheckState state = GetChecked(node.FirstNode);
foreach (TreeNode child in node.Nodes)
state &= GetChecked(child);
 
if (InternalSetChecked(node, state))
{
ChangeParent(node.Parent);
}
}
 
/// ------------------------------------------------------------------------------------
/// <summary>
/// Handles changing the state of a node
/// </summary>
/// <param name="node"></param>
/// ------------------------------------------------------------------------------------
protected void ChangeNodeState(TreeNode node)
{
if (node.ForeColor != mDisabledNodeColor)
{
BeginUpdate();
CheckState newState;
if (node.ImageIndex == (int)CheckState.Unchecked || node.ImageIndex < 0)
{
newState = CheckState.Checked;
}
else
{
newState = CheckState.Unchecked;
}
CheckNode(node, newState);
ChangeParent(node.Parent);
EndUpdate();
}
}
 
/// ------------------------------------------------------------------------------------
/// <summary>
/// Sets the checked state of a node, but doesn't deal with children or parents
/// </summary>
/// <param name="node">Node</param>
/// <param name="state">The new checked state</param>
/// <returns><c>true</c> if checked state was set to the requested state, otherwise
/// <c>false</c>.</returns>
/// ------------------------------------------------------------------------------------
private bool InternalSetChecked(TreeNode node, CheckState state)
{
bool returnValue = true;
if (node.ForeColor != mDisabledNodeColor)
{
TreeViewCancelEventArgs args = new TreeViewCancelEventArgs(node, false, TreeViewAction.Unknown);
OnBeforeCheck(args);
if (args.Cancel)
{
returnValue = false;
}
 
node.ImageIndex = (int)state;
node.SelectedImageIndex = (int)state;
 
OnAfterCheck(new TreeViewEventArgs(node, TreeViewAction.Unknown));
}
else
{
returnValue = false;
}
return returnValue;
}
 
/// ------------------------------------------------------------------------------------
/// <summary>
/// Build a list of all of the tag data for checked items in the tree.
/// </summary>
/// <param name="node"></param>
/// <param name="list"></param>
/// ------------------------------------------------------------------------------------
private void BuildTagDataList(TreeNode node, ArrayList list)
{
if (GetChecked(node) == CheckState.Checked && node.Tag != null)
list.Add(node.Tag);
 
foreach (TreeNode child in node.Nodes)
BuildTagDataList(child, list);
}
 
/// ------------------------------------------------------------------------------------
/// <summary>
/// Look through the tree nodes to find the node that has given tag data and check it.
/// </summary>
/// <param name="node"></param>
/// <param name="tag"></param>
/// <param name="state"></param>
/// ------------------------------------------------------------------------------------
private void FindAndCheckNode(TreeNode node, object tag, CheckState state)
{
if (node.Tag != null && node.Tag.Equals(tag))
{
SetChecked(node, state);
return;
}
 
foreach (TreeNode child in node.Nodes)
FindAndCheckNode(child, tag, state);
}
#endregion
 
#region Public methods
/// ------------------------------------------------------------------------------------
/// <summary>
/// Gets the checked state of a node
/// </summary>
/// <param name="nodeName">Node name</param>
/// <returns>The checked state</returns>
/// ------------------------------------------------------------------------------------
public CheckState GetChecked(string nodeName)
{
CheckState returnCheckState = CheckState.GreyChecked;
 
TreeNode[] nodes = this.Nodes.Find(nodeName, true);
if (nodes != null && nodes.Length > 0)
{
returnCheckState = GetChecked(nodes[0]);
}
else
{
throw new Exception("Node " + nodeName + " not found.");
}
return returnCheckState;
}
 
/// ------------------------------------------------------------------------------------
/// <summary>
/// Gets the checked state of a node
/// </summary>
/// <param name="node">Node</param>
/// <returns>The checked state</returns>
/// ------------------------------------------------------------------------------------
public CheckState GetChecked(TreeNode node)
{
if (node.ImageIndex < 0)
return CheckState.Unchecked;
else
return (CheckState)node.ImageIndex;
}
 
/// ------------------------------------------------------------------------------------
/// <summary>
/// Sets the checked state of a node
/// </summary>
/// <param name="node">Node</param>
/// <param name="state">The new checked state</param>
/// ------------------------------------------------------------------------------------
public void SetChecked(TreeNode node, CheckState state)
{
bool stateChanged = InternalSetChecked(node, state);
 
if (stateChanged)
{
CheckNode(node, state);
}
ChangeParent(node.Parent);
}
 
/// ------------------------------------------------------------------------------------
/// <summary>
/// Find a node in the tree that matches the given tag data and set its checked state
/// </summary>
/// <param name="tag"></param>
/// <param name="state"></param>
/// ------------------------------------------------------------------------------------
public void CheckNodeByTag(object tag, CheckState state)
{
if (tag == null)
return;
foreach (TreeNode node in Nodes)
FindAndCheckNode(node, tag, state);
}
 
/// ------------------------------------------------------------------------------------
/// <summary>
/// Return a list of the tag data for all of the checked items in the tree
/// </summary>
/// <returns></returns>
/// ------------------------------------------------------------------------------------
public ArrayList GetCheckedTagData()
{
ArrayList list = new ArrayList();
 
foreach (TreeNode node in Nodes)
BuildTagDataList(node, list);
return list;
}
#endregion
}
}

 
modified on Tuesday, October 13, 2009 12:07 PM

GeneralRe: Added ability to have disabled nodes. You might find this usefull.membergiova12 Oct '09 - 22:53 
Thank you for your code Muad'Dubby.
Unfortunatly your past failed, look at the last line of your code :
if (nodes != null && nodes.Length > 
seems like something is missing isn't it? Smile | :)
GeneralRe: Added ability to have disabled nodes. You might find this usefull.memberMuaddubby13 Oct '09 - 5:07 
Yes, sorry about that. I'll post the correct code shortly.
 

GeneralRe: Added ability to have disabled nodes. You might find this usefull.memberMuaddubby13 Oct '09 - 6:07 
Looks like all the code is available within my comment, but is not being displayed. Probably a maximum string length was hit or something.
 
In any case, here is the rest of the code, starting from (and including) the last line which appears truncated in my first note). Sorry about this!
 
if (nodes != null && nodes.Length > 0)
{
returnCheckState = GetChecked(nodes[0]);
}
else
{
throw new Exception("Node " + nodeName + " not found.");
}
return returnCheckState;
}
 
/// ------------------------------------------------------------------------------------
/// <summary>
/// Gets the checked state of a node
/// </summary>
/// <param name="node">Node</param>
/// <returns>The checked state</returns>
/// ------------------------------------------------------------------------------------
public CheckState GetChecked(TreeNode node)
{
if (node.ImageIndex < 0)
return CheckState.Unchecked;
else
return (CheckState)node.ImageIndex;
}
 
/// ------------------------------------------------------------------------------------
/// <summary>
/// Sets the checked state of a node
/// </summary>
/// <param name="node">Node</param>
/// <param name="state">The new checked state</param>
/// ------------------------------------------------------------------------------------
public void SetChecked(TreeNode node, CheckState state)
{
bool stateChanged = InternalSetChecked(node, state);
 
if (stateChanged)
{
CheckNode(node, state);
}
ChangeParent(node.Parent);
}
 
/// ------------------------------------------------------------------------------------
/// <summary>
/// Find a node in the tree that matches the given tag data and set its checked state
/// </summary>
/// <param name="tag"></param>
/// <param name="state"></param>
/// ------------------------------------------------------------------------------------
public void CheckNodeByTag(object tag, CheckState state)
{
if (tag == null)
return;
foreach (TreeNode node in Nodes)
FindAndCheckNode(node, tag, state);
}
 
/// ------------------------------------------------------------------------------------
/// <summary>
/// Return a list of the tag data for all of the checked items in the tree
/// </summary>
/// <returns></returns>
/// ------------------------------------------------------------------------------------
public ArrayList GetCheckedTagData()
{
ArrayList list = new ArrayList();
 
foreach (TreeNode node in Nodes)
BuildTagDataList(node, list);
return list;
}
#endregion
}
}

 

GeneralAbsolutely awesomememberMuaddubby26 May '09 - 3:48 
I was looking for something like this for quite some time. You got my 5!
 

Generalcontains node!membernjuniorba7 May '09 - 15:07 
Hi.. how to verify node in tri-state treeview?
 
example:
 
if(mytreeview.Contains(mynode))
{
 
}
 
I'm not obtaining to make, always it informs that it does not exist, but it exists the node
 
help please!
GeneralDisable Nodememberkjward20 Apr '09 - 4:53 
i've been using this control very successfully for a year or more...thanks ever so much for all your great work!
 
i'd like to be able to disable certain nodes based on some conditions; can this be done?
 
my current workaround is to remove the node altogether, but that has its drawbacks. it really would be better to show the node but have it disabled.
 
thanks
 
kjward

GeneralRe: Disable NodememberMuaddubby10 Jun '09 - 8:59 
Hi
 
I've had the same issue, and got around it by trapping the BeforeCheck event and testing the node that generated the event. If it's the one I want "disabled" I simply cancel the event. I also set the text of the "disabled" node to gray so the user has a visual queue.
 
Problem is - if the event was triggered because a parent node was checked off, the child will remain unchecked (which is correct), but the parent's checkbox remains checked instead of GreyChecked (or unchecked, depending on the other child nodes' states). If anyone has any ideas about how to overcome this I'd love to hear them.
 
code snippet:
private void mTriStateTreeView_BeforeCheck(object sender, TreeViewCancelEventArgs e)
{
   if (mRadioButtonComplianceEngine.Checked && !mDisablingSourceNodes)
   {
      if (e.Node.ForeColor == SystemColors.GrayText)
      {
          e.Cancel = true;
      }
   }
}

 

GeneralRe: Disable NodememberMuaddubby18 Jun '09 - 10:29 
Hi Again
 
I kept on working on this and came up with a fix that works perfectly for this. See the note I left on June 19 2009, titled "Added ability to have disabled nodes. You might find this usefull. ".
 

QuestionTriStateTreeView in Oracle Forms 6imemberchrisvelarde14 Mar '09 - 21:14 
Hi,
 
The .NET Framework TreeView works fine under Oracle Forms 6i environment and I would like to improve my existing application using the TriStateTreeView instead. Oracle´s Developer 2000 is becoming out of date, but there are still a lot of people/clients that use systems build with it. Is there a way to make the TriStateTreeView compatible with older IDEs? Confused | :confused:
 
Only to mention an example, I wasn't able to register the necessary dll files in order to reutilize them as an ActiveX component.
 
I´d appreciate any comments.
 
Thanks in advance.
Generalnice workmemberdrakej11 Oct '08 - 6:39 
The idea of setting both the selected and unselected images for a node to one of the three desired states was not obvious, at least to me when I tried to solve this on my own. Very nice! Thanks.
Generalsuppper control... tx a lot. hat off for the author and code projectmemberkasunth10 Sep '08 - 2:56 
Big Grin | :-D
 
i'am begnier to the Software engineering field.therefore i would like to refer your site

GeneralAwesome Control!memberkjward6 Sep '08 - 4:57 
thanks ever so much for creating this very cool control. i was using a vs2005 treeview that's populated from an oracle stored procedure resulting in a very complex tree hierarchy. i put your control on my form next to that one as a test, simply changed the name in my data load method to this new control, and voila! everything works exactly the way i was hoping it would with virtually no additional coding!
 
u da man!
 
keep up the great work...and thanks again!
 
kjward

QuestionError using control in VS 2005 (c#)memberNIPI23 Apr '08 - 0:10 
Hello! When i additing the TriStateTreeView control on a form an error: Failed to create component... Could not find any resources appropriate for the specified culture or the neutral culture...
What is the problem???
GeneralThis is usable in VB as well!memberjonmach18 Nov '07 - 7:11 

I had a number of problems with the TriStateTreeView class in VB on this site, but would you believe it, it is possible to simply add the .cs file from this project, and add references to the two dll's, and it works perfectly as a valid VB class.
 
Damn if that isn't outstanding.
 
Cool | :cool:
GeneralTreeView bugmembermjelten29 Jul '07 - 23:14 
Great Control!
 
I am using CheckBoxes = true.
I notice that when you change Theme in Windows from Windows XP to Windows classic or reverse the TreeView does not Update, you has to restart the application. Anyone know how to fix this or how to work around it?
 

Generalcheck box can't be displayedmemberjustanumber29 Jul '07 - 6:21 
I added the TriStateTreeView control on my form, but a check box isn't displayed near the name of the node. I can see that there is some free place where the boxes should appear, but they don't appear, like the images of the boxes can't be loaded. And when i click on them the AfterCheck event is fired.
 
What am i don't wrrong. I added the 2 dlls as references in my project, and also the .cs file. I can use the control but the checkboxes don't appear Frown | :(
 
Anybody having the same problem?
GeneralRe: check box can't be displayedmemberCodeForFun20 Sep '07 - 7:49 
Having same problem. Does anyone have a clue?WTF | :WTF:

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

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 2 Nov 2005
Article Copyright 2004 by Ebse
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid