Questions tagged [treenode]

The base element of a hierarchical tree-like data structure.

Trees are hierarchical data structures that represent undirected acyclic graphs. A tree is therefore composed of connected nodes.

One specific node is the root of the tree. The root node is connected to several nodes (sometimes called children), each of these being the root of a subtree, and so-on. A node of a tree that does not have any children is called a leaf. All nodes of the tree are connected directly or indirectly to the root.

Treenodes are usually recursive datastructures.

See also:

Specific usages:

  • In .Net framework a TreeNode is a node in TreeView UI control that displays tree-like objects.
  • In Java a TreeNode is an interface that nodes of a JTree UI control that displays tree-like objects.
586 questions
34
votes
6 answers

C# WinForms highlight treenode when treeview doesn't have focus

I'm making an interface to edit scenarios for a game. Basically it consists of events, which have nested conditions and actions. So, I planned on using two treeviews - one for selecting the event, and other for selecting the condition/action inside…
Istrebitel
  • 2,715
  • 6
  • 29
  • 45
26
votes
4 answers

Is there a method for searching for TreeNode.Text field in TreeView.Nodes collection?

Like this: TreeNode[] treeNodes = treeView.Nodes.Find(searchString, true); but I want it to search in the text field instead of the name field.
Romz
  • 1,317
  • 4
  • 29
  • 60
20
votes
4 answers

How to disable a WinForms TreeView node checkbox?

I need to be able to disable some of the checkboxes in a TreeView control of a WinForms application, but there's no such functionality built-in to the standard TreeView control. I am already using the TreeView.BeforeCheck event and cancel it if the…
Vassili Altynikov
  • 2,049
  • 2
  • 17
  • 24
20
votes
5 answers

How can I determine if the selected node is a child or parent node in TreeView?

How can I find out if the selected node is a child node or a parent node in the TreeView control?
Priyanka
  • 2,732
  • 14
  • 53
  • 87
16
votes
4 answers

C#: How to avoid TreeNode check from happening on a double click event

So I have a TreeView in a C# windows form app. What I need is for some nodes to be "locked" so that they cannot be checked (or unchecked), based on a parameter. What I am doing now is this: private void tv_local_BeforeCheck(object sender,…
Toadums
  • 2,613
  • 7
  • 40
  • 67
13
votes
1 answer

Java: How to programmatically select and expand multiple nodes in a JTree?

I have a JTree and an awt.Canvas. When i select multiple objects from within the Canvas into the objList, I want all the selected items to be shown inside the JTree as selected. That means for example if I have 2 objects selected, both their paths…
Pantaziu Cristian
  • 802
  • 2
  • 12
  • 26
12
votes
2 answers

Set icon to each node in Jtree

I want to set for each node in my JTree a different icon, actually I'm loading each node from a data base, with a "while", I set each icon like a root, leaf or parent. Like this: All my declarations are global: private ResultSet…
Vlad
  • 190
  • 1
  • 3
  • 13
11
votes
4 answers

How do you get the root node or the first level node of the selected node in a tree view?

Are there more straight forward method than the code below to get the root nodes or the first level nodes in a tree view? TreeNode node = treeView.SelectedNode; while(node != null) { node = node.Parent; }
LEMUEL ADANE
  • 6,680
  • 14
  • 48
  • 64
11
votes
8 answers

Algorithm to calculate the most energy efficient ad-hoc network

I have a (theoretical) network with N nodes, each with their own fixed location. Each node sends one message per cycle, which needs to reach the root either directly or via other nodes. The energy cost of sending a message from node A to node B is…
Meir
  • 10,735
  • 19
  • 56
  • 70
11
votes
4 answers

Is the root node an internal node?

So I've looked around the web and a couple of questions here in stackoverflow here are the definition: Generally, an internal node is any node that is not a leaf (a node with no children) Non-leaf/Non-terminal/Internal node – has at least one child…
thedoublejointedprince
  • 3,660
  • 11
  • 48
  • 66
10
votes
1 answer

Treeview Node click behavior

I have a Winform application where I am using TreeView. Some users of this application have a problem that they must double click on a node to expand it. So I added this code to use single click to expand nodes: Private Sub…
DanielH
  • 883
  • 10
  • 28
9
votes
1 answer

TreeNode.EndEdit vs NodeLabelEditEventArgs.CancelEdit

What is the difference between TreeNode.EndEdit and setting NodeLabelEditEventArgs.CancelEdit?
dan gibson
  • 3,503
  • 3
  • 35
  • 56
9
votes
2 answers

JTree set background of node to non-opaque

Please have a look at the SSCCE. How can I make the non-selected tree nodes' background transparent. At the moment the background of non-selected nodes is white. My cell renderer, however, should paint it non-opaque if it is not selected (and green…
haferblues
  • 1,963
  • 3
  • 24
  • 35
8
votes
6 answers

How to deep copy a Binary Tree?

I would like using my own Node class to implement tree structure in Java. But I'm confused how to do a deep copy to copy a tree. My Node class would be like this: public class Node{ private String value; private Node leftChild; private Node…
lkkeepmoving
  • 2,023
  • 5
  • 21
  • 30
8
votes
3 answers

TreeView search

This function find only first node in treeview, that contains SearchText. private TreeNode SearchNode(string SearchText,TreeNode StartNode) { TreeNode node=null; while (StartNode!= null) { if…
Romz
  • 1,317
  • 4
  • 29
  • 60
1
2 3
39 40