 |
|
 |
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!
|
|
|
|
 |
|
 |
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
|
|
|
|
 |
|
 |
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;
}
}
}
|
|
|
|
 |
|
 |
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. ".
|
|
|
|
 |
|
 |
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?
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.
|
|
|
|
 |
|
 |
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.
|
|
|
|
 |
|
 |
i'am begnier to the Software engineering field.therefore i would like to refer your site
|
|
|
|
 |
|
 |
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
|
|
|
|
 |
|
 |
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???
|
|
|
|
 |
|
 |
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.
|
|
|
|
 |
|
 |
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?
|
|
|
|
 |
|
 |
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
Anybody having the same problem?
|
|
|
|
 |
|
 |
Having same problem. Does anyone have a clue?
|
|
|
|
 |
|
|
 |
|
 |
Is it possible with the code to call the OnBeforeCeck(e) method instead?
or, what I really want to do is to be able to know whent the TreeView has updated all nodes, so I can Save the states of the nodes and be able to copy them to another TreeView. Any suggestions?
-- modified at 4:32 Friday 20th July, 2007
|
|
|
|
 |
|
 |
I need to reset all options to unchecked. How would I do that?
|
|
|
|
 |
|
 |
hi I have a problem where I have to add 3 images on same tree node. these images have to be placed side by side.. Is there some way i can do it.. Thanks in advance..
|
|
|
|
 |
|
 |
Hi...
I test in a Windows Application and works fine...
But in a Smart Device Application (Pocket PC 2003) the component are desactevated in Toolbox...
How I use this control in A Smart Device Application?
Thanks
|
|
|
|
 |
|
 |
Hi!
Im making a Database access program and like this tri-state method for sorting the tables. Im getting this to sort the tables as thay should, how ever. When I try to call what boxes are checked there is no output. from the ArrayList.
Right now I have a peace of code that is run when Connect/Refresh button is pushed.
It looks like this.
public void scThreeCheckedChoises()
{
ArrayList ChkList = new ArrayList();
ChkList = dcTriStateTreeView2.GetCheckedTagData();
string test = System.String.Concat(ChkList.ToArray());
string ChkStr = "";
foreach (string s in ChkList)
{
ChkStr = s;
}
MessageBox.Show(ChkStr);
MessageBox.Show(test);
}
I want it to a singel string row as it should talk to the SQL server what tables to select.
I get nothing out at all, shouldnt I use .GetCheckedData to retrive the checked alternativs in treeview? Would be grate If anyone could help.
|
|
|
|
 |
|
 |
I tried to do a count command on the ArrayList but it replays "0" no matter how it is checked.
ArrayList ChkList = new ArrayList();
ChkList = triStateTreeView1.GetCheckedTagData();
MessageBox.Show(ChkList.Count.ToString());
Seems like there is a problem with the code that should count the checked alternatives. Or?
|
|
|
|
 |
|
 |
I Solved the problem. re wrote some code.
public ArrayList CountTheChecked = new ArrayList();
private void BuildTagDataList(TreeNode node, ArrayList list)
{
foreach (TreeNode child in node.Nodes)
{
if (GetChecked(child) == CheckState.Checked && child.Text != "")
{
CountTheChecked.Add(child.Text);
}
}
}
This can then be calld and will return the checked children.
|
|
|
|
 |
|
 |
You can also check what the imageindex is set to. 1 is OFF, 2 is ON, and I assume that 3 is indeterminite.
bNowActive = (tnNode.ImageIndex = 2)
if (bNowActive = true) then
' do the stuff for the checked item
else
' do the stuff for the unchecked item
end if
At least that's what I did when using this in VB.Net. It should be the same here.
|
|
|
|
 |
|
 |
Images are mirrored in the Right-To-Left Layout ?!
Advice ...
Ahmed Amin El-Morali
S/W Developer
EGYPT
|
|
|
|
 |
|
 |
Hello
I used a more simple code to mimics a three-state treeview. I use the StateImageList property instead. See the code below:
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
namespace Sample
{
public class ThreeStateTreeView : TreeView
{
private const int STATE_UNCHECKED = 0; //unchecked state
private const int STATE_CHECKED = 1; //checked state
private const int STATE_MIXED = 2; //mixed state (indeterminate)
private ImageList _InternalStateImageList; //state image list
//create a new ThreeStateTreeView
public ThreeStateTreeView()
: base()
{
}
//initialize all nodes state image
public void InitializeNodesState(TreeNodeCollection nodes)
{
foreach (TreeNode node in nodes)
{
node.StateImageIndex = 0;
if (node.Nodes.Count != 0)
{
InitializeNodesState(node.Nodes);
}
}
}
//update children state image with the parent value
public void UpdateChildren(TreeNode parent)
{
int state = parent.StateImageIndex;
foreach (TreeNode node in parent.Nodes)
{
node.StateImageIndex = state;
if (node.Nodes.Count != 0)
{
UpdateChildren(node);
}
}
}
//update parent state image base on the children state
public void UpdateParent(TreeNode child)
{
TreeNode parent = child.Parent;
if (parent == null)
{
return;
}
if (child.StateImageIndex == STATE_MIXED)
{
parent.StateImageIndex = STATE_MIXED;
}
else if (IsChildrenChecked(parent))
{
parent.StateImageIndex = STATE_CHECKED;
}
else if (IsChildrenUnchecked(parent))
{
parent.StateImageIndex = STATE_UNCHECKED;
}
else
{
parent.StateImageIndex = STATE_MIXED;
}
UpdateParent(parent);
}
//returns a value indicating if all children are checked
public static bool IsChildrenChecked(TreeNode parent)
{
return IsAllChildrenSame(parent, STATE_CHECKED);
}
//returns a value indicating if all children are unchecked
public static bool IsChildrenUnchecked(TreeNode parent)
{
return IsAllChildrenSame(parent, STATE_UNCHECKED);
}
//returns a value indicating if all children are in the same state
public static bool IsAllChildrenSame(TreeNode parent, int state)
{
foreach (TreeNode node in parent.Nodes)
{
if (node.StateImageIndex != state)
{
return false;
}
if (node.Nodes.Count != 0 && !IsAllChildrenSame(node, state))
{
return false;
}
}
return true;
}
//build the checked, unchecked and indeterminate images
private static Image GetStateImage(CheckBoxState state, Size imageSize)
{
Bitmap bmp = new Bitmap(16, 16);
using (Graphics g = Graphics.FromImage(bmp))
{
Point pt = new Point((16 - imageSize.Width) / 2, (16 - imageSize.Height) / 2);
CheckBoxRenderer.DrawCheckBox(g, pt, state);
}
return bmp;
}
protected override void OnHandleCreated(EventArgs e)
{
base.OnHandleCreated(e);
if (_InternalStateImageList == null)
{
_InternalStateImageList = new ImageList();
using (Graphics g = base.CreateGraphics())
{
Size glyphSize = CheckBoxRenderer.GetGlyphSize(g, CheckBoxState.UncheckedNormal);
_InternalStateImageList.Images.Add(GetStateImage(CheckBoxState.UncheckedNormal, glyphSize));
_InternalStateImageList.Images.Add(GetStateImage(CheckBoxState.CheckedNormal, glyphSize));
_InternalStateImageList.Images.Add(GetStateImage(CheckBoxState.MixedNormal, glyphSize));
_InternalStateImageList.Images.Add(GetStateImage(CheckBoxState.UncheckedDisabled, glyphSize));
_InternalStateImageList.Images.Add(GetStateImage(CheckBoxState.CheckedDisabled, glyphSize));
_InternalStateImageList.Images.Add(GetStateImage(CheckBoxState.MixedDisabled, glyphSize));
}
}
base.StateImageList = _InternalStateImageList;
InitializeNodesState(base.Nodes);
}
//check if user click on the state image
protected override void OnMouseClick(MouseEventArgs e)
{
base.OnMouseClick(e);
if (e.Button == MouseButtons.Left)
{
TreeViewHitTestInfo info = base.HitTest(e.Location);
if (info.Node != null && info.Location == TreeViewHitTestLocations.StateImage)
{
TreeNode node = info.Node;
switch (node.StateImageIndex)
{
case STATE_UNCHECKED:
case STATE_MIXED:
node.StateImageIndex = STATE_CHECKED;
break;
case STATE_CHECKED:
node.StateImageIndex = STATE_UNCHECKED;
break;
}
UpdateChildren(node);
UpdateParent(node);
}
}
}
//check if user press the space key
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
if (e.KeyCode == Keys.Space)
{
if (base.SelectedNode != null)
{
TreeNode node = base.SelectedNode;
switch (node.StateImageIndex)
{
case STATE_UNCHECKED:
case STATE_MIXED:
node.StateImageIndex = STATE_CHECKED;
break;
case STATE_CHECKED:
node.StateImageIndex = STATE_UNCHECKED;
break;
}
UpdateChildren(node);
UpdateParent(node);
}
}
}
//swap between enabled and disabled images
protected override void OnEnabledChanged(EventArgs e)
{
base.OnEnabledChanged(e);
for (int i = 0; i < 3; i++)
{
Image img = _InternalStateImageList.Images[0];
_InternalStateImageList.Images.RemoveAt(0);
_InternalStateImageList.Images.Add(img);
}
}
}
}
|
|
|
|
 |
|
 |
Excellent! This is by far the most simple and straight forward implementation of a three state checkboxed tree view control with themed checkboxes.
|
|
|
|
 |